RE: [PATCH 2/2] Drop filename length limit in CPIO extraction
diff mbox series

Message ID BY1PR17MB0120A13E43E7CD1C66C078FBF1020@BY1PR17MB0120.namprd17.prod.outlook.com
State Not Applicable
Headers show
Series
  • RE: [PATCH 2/2] Drop filename length limit in CPIO extraction
Related show

Commit Message

richard_allen@keysight.com Dec. 22, 2017, 1:42 p.m. UTC
Thanks! I appreciate this, should fix our issue.
Dick


-----Original Message-----
From: Stefano Babic [mailto:sbabic@denx.de] 
Sent: Friday, December 22, 2017 1:41 AM
To: swupdate@googlegroups.com
Cc: ALLEN,RICHARD (K-SantaClara,ex1) <richard_allen@keysight.com>; Stefano Babic <sbabic@denx.de>
Subject: [PATCH 2/2] Drop filename length limit in CPIO extraction

Signed-off-by: Stefano Babic <sbabic@denx.de>
Reported-by: Richard Alled <richard_allen@keysight.com>
---
 corelib/installer.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

 			continue;
 
 		if (!fromfile) {
-			if (snprintf(filename, sizeof(filename), "%s%s",
-				     TMPDIR, img->fname) >= (int)sizeof(filename)) {
+		    if (asprintf(&filename, "%s%s", TMPDIR, img->fname) ==
+				ENOMEM_ASPRINTF) {
 				ERROR("Path too long: %s%s", TMPDIR, img->fname);
 				return -1;
 			}
@@ -304,11 +304,13 @@ int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile)
 			ret = stat(filename, &buf);
 			if (ret) {
 				TRACE("%s not found or wrong", filename);
+				free(filename);
 				return -1;
 			}
 			img->size = buf.st_size;
 
 			img->fdin = open(filename, O_RDONLY);
+			free(filename);
 			if (img->fdin < 0) {
 				ERROR("Image %s cannot be opened",
 				img->fname);
--
2.7.4

Patch
diff mbox series

diff --git a/corelib/installer.c b/corelib/installer.c index c63de49..4890e83 100644
--- a/corelib/installer.c
+++ b/corelib/installer.c
@@ -252,7 +252,7 @@  int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile)  {
 	int ret;
 	struct img_type *img;
-	char filename[64];
+	char *filename;
 	struct filehdr fdh;
 	struct stat buf;
 	const char* TMPDIR = get_tmpdir();
@@ -295,8 +295,8 @@  int install_images(struct swupdate_cfg *sw, int fdsw, int fromfile)