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 <fishbaozi@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/73647
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
This commit is contained in:
Zheng Bao 2023-03-11 10:29:56 +08:00 committed by Martin L Roth
parent 7391722c40
commit 17551ae865
1 changed files with 2 additions and 1 deletions

View File

@ -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) {