This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] vfprintf: validate nargs and maybe allocate from heap
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.