mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-28 15:41:40 +00:00
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 <sjg@chromium.org> Reported-by: Coverity (CID: 150964)
This commit is contained in:
parent
eb9e699ff1
commit
ae3de0d8ca
1 changed files with 4 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue