diff mbox series

Fix coverity #292179

Message ID 20200415082525.11453-4-sbabic@denx.de
State Accepted
Headers show
Series Fix coverity #292113 | expand

Commit Message

Stefano Babic April 15, 2020, 8:25 a.m. UTC
Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 core/swupdate.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/core/swupdate.c b/core/swupdate.c
index e4d9d2c..67e9b9d 100644
--- a/core/swupdate.c
+++ b/core/swupdate.c
@@ -427,9 +427,14 @@  static int parse_image_selector(const char *selector, struct swupdate_cfg *sw)
 }
 
 static void create_directory(const char* path) {
-	char* dpath = alloca(strlen(get_tmpdir())+strlen(path)+1);
-	sprintf(dpath, "%s%s", get_tmpdir(), path);
+	char* dpath;
+	if (asprintf(&dpath, "%s%s", get_tmpdir(), path) ==
+		ENOMEM_ASPRINTF) {
+		ERROR("OOM: Directory %s not created", path);
+		return;
+	}
 	mkdir(dpath, 0777);
+	free(dpath);
 }
 
 #ifndef CONFIG_NOCLEANUP