[PATCH] vfprintf: validate nargs and maybe allocate from heap

Paul Eggert eggert@cs.ucla.edu
Mon Feb 6 19:43:00 GMT 2012


On 02/06/2012 09:20 AM, Kees Cook wrote:
>>             specs = extend_alloca (specs, nspecs_size, 2 * nspecs_size);
> This on in particular I've looked at and have mostly convinced myself that
> it is okay, since it must constantly copy the previous memory into the
> newly allocated region.

The copying is safe; it's the allocation calculation
that might not be safe.  Couldn't it be that
nspecs_size > SIZE_MAX / 2, so that 2 * nspecs_size overflows?
We must also make sure the previous expression
nspecs * sizeof (*specs) doesn't overflow.
That sort of thing.



More information about the Libc-alpha mailing list