This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 1/3] posix: Remove dynamic memory allocation from execl{e,p}


On Mon, Feb 01, 2016 at 04:52:15PM +0000, Joseph Myers wrote:
> On Mon, 1 Feb 2016, Adhemerval Zanella wrote:
> 
> > +  char *argv[argc+1];
> > +  va_start (ap, arg);
> > +  argv[0] = (char*) arg;
> > +  for (i = 1; i < argc; i++)
> > +     argv[i] = va_arg (ap, char *);
> > +  argv[i] = NULL;
> 
> I don't see how you're ensuring this stack allocation is safe (i.e. if 
> it's too big, it doesn't corrupt memory that's in use by other threads).  

There's no obligation to. If you pass something like a million
arguments to a variadic function, the compiler will generate code in
the caller that overflows the stack before the callee is even reached.
The size of the vla used in execl is exactly the same size as the
argument block on the stack used for passing arguments to execl from
its caller, and it's nobody's fault but the programmer's if this is
way too big. It's not a runtime variable.

Rich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]