]> git.baikalelectronics.ru Git - uboot.git/commit
console: file should always be non-negative
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sat, 22 Oct 2022 09:32:34 +0000 (11:32 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 2 Dec 2022 18:17:24 +0000 (19:17 +0100)
commit6b35788f34e14ebe98a4f696c41c78bcff01afc5
tree73a1386b8b976e0bea29f05e15d38bad7a9e67c1
parent7ab54e76f09a8d7938c7dd47d6c4b9dc9e3928df
console: file should always be non-negative

We use the parameter file in console functions to choose from an array
after checking against MAX_FILES but we never check if the value of file
is negative.

Running ./u-boot -T -l and issuing the poweroff command has resulted in
crashes because os_exit() results in std::ostream::flush() calling U-Boot's
fflush with file being a pointer which when converted to int may be
represented by a negative number.

This shows that checking against MAX_FILES is not enough. We have to ensure
that the file argument is always positive.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
common/console.c