Skip to contentSkip to conversation

mkimage: Fix missing free() in show_valid_options()

PATCH Superseded Simon Glass 2 participants 3 messages Oct 27, 2016 – Nov 2, 2016

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 mkimage: Fix missing free() in show_valid_options()

The allocated memory should be freed. Fix it.

Reported-by Coverity (CID: 150963)

---

Changes in v2: None

 tools/mkimage.c | 1 +
 1 file changed, 1 insertion(+)
tools/mkimage.c +1 -0
index 3c594a0..521fa80 100644
@@ -64,6 +64,7 @@ static int show_valid_options(enum ih_category category)
 			genimg_get_cat_name(category, item));
 	}
 	fprintf(stderr, "\n");
+	free(order);
 
 	return 0;
 }
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH v2 2/2 image: Protect against overflow in unknown_msg()

Coverity complains that this can overflow. If we later increase the size of one of the strings in the table, it could happen.

Adjust the code to protect against this.

Reported-by Coverity (CID: 150964)

---

Changes in v2:
- Drop unwanted #include

 common/image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/image.c +1 -1
index 0e86c13..4255267 100644
@@ -590,7 +590,7 @@ static const char *unknown_msg(enum ih_category category)
 	static char msg[30];
 
 	strcpy(msg, "Unknown ");
-	strcat(msg, table_info[category].desc);
+	strncat(msg, table_info[category].desc, sizeof(msg) - 1);
 
 	return msg;
 }
Signature · 1 line
2.8.0.rc3.226.g39d4020
#2 lore raw

PATCH v2 1/2 mkimage: Fix missing free() in show_valid_options()

In reply to Simon Glass
Quoted 5 lines · Simon Glass

The allocated memory should be freed. Fix it.

Reported-by Coverity (CID: 150963)

Applied to u-boot/master (before v2016.11-rc3), thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161102/fcba2547/attachment.sig>