]> git.baikalelectronics.ru Git - uboot.git/commit
cmd: setexpr: fix printf_str()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 22 Aug 2023 10:21:13 +0000 (12:21 +0200)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Wed, 23 Aug 2023 06:02:59 +0000 (08:02 +0200)
commit1a4b3284e96e847fa9971c3d5ee364934307df70
tree6bb771c48fe1605ef861c2519d14a9362a478ff5
parentcbb70b98259666bce683165d7e4be3efc8930d62
cmd: setexpr: fix printf_str()

If vsnprintf() returns a negative number, (i >= remaining) will
possibly be true:

'i' is of type signed int and 'remaining' is of the unsigned type size_t.
The C language will convert i to an unsigned type before the comparison.

This can result in the wrong error type being indicated.

Checking for negative i should be done first.

Fixes: 985f0d2fcf94 ("cmd: setexpr: add format string handling")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/printf.c