Attention is currently required from: Zheng Bao. Hello Zheng Bao,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/62482
to review the following change.
Change subject: amdfwtool: Clear struct match before regular expression matching ......................................................................
amdfwtool: Clear struct match before regular expression matching
If it is not cleared and the number of strings is fewer than last iteration, the match[3] will keep the last value.
Change-Id: If14e0923fbb1648d83784eb5dc1411c93227db5a Signed-off-by: Zheng Bao fishbaozi@gmail.com --- M util/amdfwtool/data_parse.c 1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/82/62482/1
diff --git a/util/amdfwtool/data_parse.c b/util/amdfwtool/data_parse.c index a6b73ee..7f9816b 100644 --- a/util/amdfwtool/data_parse.c +++ b/util/amdfwtool/data_parse.c @@ -428,10 +428,12 @@ return OK; }
+#define N_MATCHES 4 static int is_valid_entry(char *oneline, regmatch_t *match) { int retval;
+ memset (match, 0, sizeof(regmatch_t) * N_MATCHES); if (regexec(&entries_line_expr, oneline, 3, match, 0) == 0) { oneline[match[1].rm_eo] = '\0'; oneline[match[2].rm_eo] = '\0'; @@ -467,7 +469,6 @@ return retval; }
-#define N_MATCHES 4 /* return value: 0: The config file can not be parsed correctly.