fiasco: fiasco_alloc_from_file: check if hwrevs has enough size

This commit is contained in:
Pali Rohár committed 2014-10-19 18:26:47 +02:00
1 parent c88e5264c9
commit d6eba11357
1 file changed
+6 -3
+6 -3
View File
@@ -192,9 +192,12 @@ struct fiasco * fiasco_alloc_from_file(const char * file) {
if ( ! hwrevs[0] )
strcpy(hwrevs, hwrev);
else {
/* TODO: check if hwrevs has enough size */
strcat(hwrevs, ",");
strcat(hwrevs, hwrev);
size_t len1 = strlen(hwrevs);
size_t len2 = strlen(hwrev);
if ( len1 + len2 + 2 < sizeof(hwrevs) ) {
hwrevs[len1] = ',';
memcpy(hwrevs+len1+1, hwrev, len2+1);
}
}
VERBOSE(" hw revision: %s\n", hwrev);
pbuf += strlen(hwrev) + 1;