diff options
author | Simon Glass <sjg@chromium.org> | 2016-10-31 10:21:09 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-11-05 07:27:43 -0400 |
commit | ae3de0d8caf1822da076b2cc947ea89a0b560e05 (patch) | |
tree | 8348f8a2ccd74d8b9767bbdb0444053efa8a2959 /common/image.c | |
parent | eb9e699ff14436c3417c949120c226531e81f614 (diff) | |
download | u-boot-ae3de0d8caf1822da076b2cc947ea89a0b560e05.tar.gz u-boot-ae3de0d8caf1822da076b2cc947ea89a0b560e05.tar.bz2 u-boot-ae3de0d8caf1822da076b2cc947ea89a0b560e05.zip |
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)
Diffstat (limited to 'common/image.c')
-rw-r--r-- | common/image.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/common/image.c b/common/image.c index 0e86c13a88..7604494a56 100644 --- a/common/image.c +++ b/common/image.c @@ -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; } |