[PATCH] pytest: fix out of bounds access to bad_pattern_ids
Denis Mukhin via U-Boot <[email protected]>
| Newsgroups | gmane.comp.boot-loaders.u-boot |
|---|---|
| Message-ID | <[email protected]> |
From: Denis Mukhin <[email protected]> Current logic in ConsoleBase() mislabels every bad pattern and walks pattern past the end when the last one matches. Ensure out of bound access to bad_pattern_ids is handled correctly while processing test console output. Fixes: 8308a5eed6e6 ("test: Introduce lab mode") Signed-off-by: Denis Mukhin <[email protected]> --- I hit that while testing reset v5 series in the CI: https://github.com/dmkhn/u-boot/commits/u/x86-reset-v5/ --- test/py/console_base.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/py/console_base.py b/test/py/console_base.py index 88d444b44b88..8b373fd4d95f 100644 --- a/test/py/console_base.py +++ b/test/py/console_base.py @@ -212,24 +212,24 @@ class ConsoleBase(object): while not self.lab_mode and loop_num > 0: loop_num -= 1 while config_spl_serial and not env_spl_skipped and env_spl_banner_times > 0: - m = self.p.expect([pattern_u_boot_spl_signon, - pattern_lab_mode] + self.bad_patterns) + extra_patterns = [pattern_u_boot_spl_signon, pattern_lab_mode] + m = self.p.expect(extra_patterns + self.bad_patterns) if m == 1: self.set_lab_mode() break elif m != 0: raise BootFail('Bad pattern found on SPL console: ' + - self.bad_pattern_ids[m - 1]) + self.bad_pattern_ids[m - len(extra_patterns)]) env_spl_banner_times -= 1 if not self.lab_mode: - m = self.p.expect([pattern_u_boot_main_signon, - pattern_lab_mode] + self.bad_patterns) + extra_patterns = [pattern_u_boot_main_signon, pattern_lab_mode] + m = self.p.expect(extra_patterns + self.bad_patterns) if m == 1: self.set_lab_mode() elif m != 0: raise BootFail('Bad pattern found on console: ' + - self.bad_pattern_ids[m - 1]) + self.bad_pattern_ids[m - len(extra_patterns)]) if not self.lab_mode: self.u_boot_version_string = self.p.after while True: -- 2.54.0