[U-Boot] [PATCH v2 1/2] mkimage: Fix missing free() in show_valid_options()

The allocated memory should be freed. Fix it.
Signed-off-by: Simon Glass sjg@chromium.org Reported-by: Coverity (CID: 150963) Reviewed-by: Tom Rini trini@konsulko.com ---
Changes in v2: None
tools/mkimage.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/tools/mkimage.c b/tools/mkimage.c index 3c594a0..521fa80 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -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; }

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.
Signed-off-by: Simon Glass sjg@chromium.org Reported-by: Coverity (CID: 150964) ---
Changes in v2: - Drop unwanted #include
common/image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/image.c b/common/image.c index 0e86c13..4255267 100644 --- a/common/image.c +++ b/common/image.c @@ -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; }

On Thu, Oct 27, 2016 at 05:54:03PM -0600, Simon Glass wrote:
The allocated memory should be freed. Fix it.
Signed-off-by: Simon Glass sjg@chromium.org Reported-by: Coverity (CID: 150963) Reviewed-by: Tom Rini trini@konsulko.com
Applied to u-boot/master (before v2016.11-rc3), thanks!
participants (2)
-
Simon Glass
-
Tom Rini