vfprintf typing problem

Carlos O'Donell carlos@systemhalted.org
Mon Apr 2 23:58:00 GMT 2012


On Mon, Apr 2, 2012 at 5:48 PM, David Miller <davem@davemloft.net> wrote:
> Here's the final patch I checked in, I'm confident it addresses the
> feedback I've received over the past few days.

Excellent work, I can understand how exhausting it is to touch some of
these core pieces of code.

I know Paul suggested that we switch to size_t return and call it
read_width, but we're at the point of diminishing returns and I don't
want to burn out our wonderful volunteers.

> Thanks everyone.
>
> --------------------
> [PATCH] Tighten up vfprintf width, precision, and total length overflow handling.
>
>        With help from Paul Eggert, Carlos O'Donell, and Roland McGrath.
>        * stdio-common/printf-parse.h (read_int): Change return type to
>        'int', return -1 on INT_MAX overflow.
>        * stdio-common/vfprintf.c (vfprintf): Validate width and precision
>        against overflow of INT_MAX.  Set errno to EOVERFLOW when 'done'
>        overflows INT_MAX.  Check for overflow of in-format-string precision
>        values properly.  Use EOVERFLOW rather than ERANGE throughout.  Use
>        SIZE_MAX not INT_MAX for integer overflow test.
>        * stdio-common/printf-parsemb.c: If read_int signals an overflow,
>        skip the construct in the format string but do not record anything.
>        * stdio-common/bug22.c: Adjust to test both width/prevision
>        INT_MAX overflow as well as total length INT_MAX overflow.  Check
>        explicitly for proper errno values.

This looks good to me.

I particularly like that the width now defaults to 0 instead of
garbage in the case of overflow.

Cheers,
Carlos.



More information about the Libc-alpha mailing list