diff options
author | Zheng Bao <fishbaozi@gmail.com> | 2023-10-28 16:20:04 +0800 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2024-03-20 13:44:57 +0000 |
commit | b91f421118ff9c12955295bc88fc19ef09c4a019 (patch) | |
tree | 6237faa4a924a2a4564739be6688e611c872bc3b /util/amdfwtool | |
parent | 58b250c3017b07cd6338d1c563562dd4e25316ff (diff) |
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>
Diffstat (limited to 'util/amdfwtool')
-rw-r--r-- | util/amdfwtool/data_parse.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/util/amdfwtool/data_parse.c b/util/amdfwtool/data_parse.c index 728feae053..5e06d974b0 100644 --- a/util/amdfwtool/data_parse.c +++ b/util/amdfwtool/data_parse.c @@ -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; |