From 17551ae865d187231858e2e359b3c00d87ea042e Mon Sep 17 00:00:00 2001 From: Zheng Bao Date: Sat, 11 Mar 2023 10:29:56 +0800 Subject: [PATCH] amdfwtool: Check combo_index before checking the combo_config Otherwise Checking combo_config[++combo_index] causes Out-of-Bounds access. Change-Id: I50d466ee98edfb18c01fc7ba43e929640b33c7c1 Signed-off-by: Zheng Bao Reviewed-on: https://review.coreboot.org/c/coreboot/+/73647 Reviewed-by: Eric Lai Tested-by: build bot (Jenkins) Reviewed-by: Martin L Roth --- util/amdfwtool/amdfwtool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/amdfwtool/amdfwtool.c b/util/amdfwtool/amdfwtool.c index f16f758cf7..738123b68f 100644 --- a/util/amdfwtool/amdfwtool.c +++ b/util/amdfwtool/amdfwtool.c @@ -2789,7 +2789,8 @@ int main(int argc, char **argv) BHD2_COOKIE, &ctx); } } - } while (cb_config.use_combo && combo_config[++combo_index] != NULL); + } while (cb_config.use_combo && ++combo_index < MAX_COMBO_ENTRIES && + combo_config[combo_index] != NULL); targetfd = open(output, O_RDWR | O_CREAT | O_TRUNC, 0666); if (targetfd >= 0) {