lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 20 Nov 2020 11:16:46 -0500
From:   Steven Rostedt <>
To:     Richard Fitzgerald <>
Cc:     Petr Mladek <>, <>,
        <>, <>
Subject: Re: [PATCH] lib: vsprintf: Fix handling of number field widths in

On Fri, 20 Nov 2020 16:04:15 +0000
Richard Fitzgerald <> wrote:

> > But yeah, we could very much have cp - startp > max_chars.
> >   
> My code handles the prefix overflow, but I did it by having
> __parse_integer_limit() simply give 0 if max_chars <= 0.

Yeah, but if that's the intended result, then it needs to be commented as
such, and the comment needs to be fixed. Right now it's:

 * Convert non-negative integer string representation in explicitly given radix
 * to an integer. The maximum number of characters to convert can be given.
 * A character limit of INT_MAX is effectively unlimited since a string that
 * long is unreasonable.
 * Return number of characters consumed maybe or-ed with overflow bit.
 * If overflow occurs, result integer (incorrect) is still returned.
 * Don't you dare use this function.

That comment needs to include: "If max_chars <= 0, then this returns zero.".

-- Steve

> So if the field width isn't enough for the prefix/leading '-' and at
> least one digit, subtracting the prefix length from the field length
> will give a max_chars <= 0. And you'll get a result of 0 as in your
> '%2li%9lx' test case.
> I thought this was nice because it didn't need to add code to check
> for the prefix overflow - it comes inherently from the loop in
> __parse_integer_limit(). But I'm willing to change
> __parse_integer_limit() to take an unsigned and add explicit checks for
> the prefix/'-' overflow cases.

Powered by blists - more mailing lists