On Tue, 22 Aug 2023 at 04:21, Heinrich Schuchardt <heinrich.schucha...@canonical.com> wrote: > > 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: f4f8d8bb1abc ("cmd: setexpr: add format string handling") > Signed-off-by: Heinrich Schuchardt <heinrich.schucha...@canonical.com> > --- > cmd/printf.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >
Reviewed-by: Simon Glass <s...@chromium.org>