Skip to content
Snippets Groups Projects
Commit ae3de0d8 authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

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: default avatarSimon Glass <sjg@chromium.org>
Reported-by: Coverity (CID: 150964)
parent eb9e699f
No related branches found
No related tags found
No related merge requests found
...@@ -587,10 +587,12 @@ const table_entry_t *get_table_entry(const table_entry_t *table, int id) ...@@ -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_msg(enum ih_category category)
{ {
static const char unknown_str[] = "Unknown ";
static char msg[30]; static char msg[30];
strcpy(msg, "Unknown "); strcpy(msg, unknown_str);
strcat(msg, table_info[category].desc); strncat(msg, table_info[category].desc,
sizeof(msg) - sizeof(unknown_str));
return msg; return msg;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment