mkimage: Fix missing free() in show_valid_options()
PATCH v4 1/2 mkimage: Fix missing free() in show_valid_options()
The allocated memory should be freed. Fix it.
Signed-off-by Simon Glass <[email protected]>
Reported-by Coverity (CID: 150963)
Reviewed-by Tom Rini <[email protected]>
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
tools/mkimage.c | 1 + 1 file changed, 1 insertion(+)
tools/mkimage.c +1 -0
@@ -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
PATCH v4 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.
Signed-off-by Simon Glass <[email protected]>
Reported-by Coverity (CID: 150964)
---
Changes in v4:
- Add missing [] (tested)
Changes in v3:
- Adjust to deal with what strncpy() actually does (I think)
Changes in v2:
- Drop unwanted #include
common/image.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
common/image.c +4 -2
@@ -587,10 +587,12 @@ const table_entry_t *get_table_entry(const table_entry_t *table, int id)static const char *unknown_msg (enum ih_category category) { +static const char unknown_str[] ="Unknown " ;static char msg[30 ]; -strcpy (msg,"Unknown " ); -strcat (msg, table_info[category].desc); +strcpy (msg, unknown_str); +strncat (msg, table_info[category].desc, +sizeof (msg) -sizeof (unknown_str));return msg; }
Signature · 1 line
2.8.0.rc3.226.g39d4020