]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/image.c
image: Protect against overflow in unknown_msg()
[people/ms/u-boot.git] / common / image.c
index 0e86c13a88aa827415d98740894abe12440ed91f..7604494a567ed9cf9af14c2b58a2bc6d1fb3805d 100644 (file)
@@ -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;
 }