[PATCH 1/3] posix: Remove dynamic memory allocation from execl{e,p}
Paul Eggert
eggert@cs.ucla.edu
Thu Feb 25 08:58:00 GMT 2016
Adhemerval Zanella wrote:
> + int argc;
> + va_list ap;
> + va_start (ap, arg);
> + for (argc = 1; va_arg (ap, const char *); argc++)
> + continue;
With my "no arbitrary limits" hat on, I noticed that this has undefined behavior
if more than INT_MAX arguments are passed to execl. The existing code is no
saint in this area (it messes up badly if more than UINT_MAX args are passed),
but the new code should not make things worse, and we might as well fix the
UINT_MAX bug while we're at it.
Attached please find a contrived test case illustrating the bug on x86-64. This
test succeeds on x86-64 now (in that the program prints "execl: Cannot allocate
memory" and exits with status 0) but could crash with the proposed patch.
Perhaps you can add this to the glibc test cases while you're at it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: big.c
Type: text/x-csrc
Size: 758 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20160225/f177b317/attachment.bin>
More information about the Libc-alpha
mailing list