[U-Boot] [PATCH v2 2/2] image: Protect against overflow in unknown_msg()
Simon Glass
sjg at chromium.org
Fri Oct 28 02:38:40 CEST 2016
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 at 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;
}
--
2.8.0.rc3.226.g39d4020
More information about the U-Boot
mailing list