amdfwtool: Check sanity before filling the data array

Change-Id: I8284c35a0124ba4588d199024e28d3445c681896
Signed-off-by: Zheng Bao <fishbaozi@gmail.com>wq
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78763
Reviewed-by: Martin L Roth <gaumless@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Zheng Bao 2023-10-28 16:20:04 +08:00 committed by Felix Held
parent 58b250c301
commit b91f421118

View File

@ -618,11 +618,16 @@ static int is_valid_entry(char *oneline, regmatch_t match[N_MATCHES])
match[4]: Optional directory level to be dropped
match[6]: Optional hash table ID to put the hash for the entry
*/
oneline[match[FW_TYPE].rm_eo] = '\0';
oneline[match[FW_FILE].rm_eo] = '\0';
oneline[match[OPT_LEVEL].rm_eo] = '\0';
oneline[match[OPT_HASH_TABLE_ID].rm_eo] = '\0';
oneline[match[OPT_FWID_TYPE].rm_eo] = '\0';
if (match[FW_TYPE].rm_eo != -1)
oneline[match[FW_TYPE].rm_eo] = '\0';
if (match[FW_FILE].rm_eo != -1)
oneline[match[FW_FILE].rm_eo] = '\0';
if (match[OPT_LEVEL].rm_eo != -1)
oneline[match[OPT_LEVEL].rm_eo] = '\0';
if (match[OPT_HASH_TABLE_ID].rm_eo != -1)
oneline[match[OPT_HASH_TABLE_ID].rm_eo] = '\0';
if (match[OPT_FWID_TYPE].rm_eo != -1)
oneline[match[OPT_FWID_TYPE].rm_eo] = '\0';
retval = 1;
} else {
retval = 0;