Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug#527171: [zsh] segfaults on long environment variables



On Wed, 6 May 2009 01:38:28 +0000
Clint Adams <schizo@xxxxxxxxxx> wrote:
> On Wed, May 06, 2009 at 02:35:05AM +0200, Nico Golde wrote:
> > export BLA=$(perl -e "print 'A' x 100000000;")
> > 
> > results in zsh segfaulting:
> > [335969.515454] zsh[29005]: segfault at 7fff1b357858 ip 7fb5184a5855 sp 7fff1b357860 error 6 in libc-2.9.so[7fb518471000+149000]
> 
> The segfault is not in the assignment but in the export (zputenv).

This appears to be failing within setenv() which (as far as I can tell)
is being passed a perfectly valid string.  setenv() is supposed to fail
gracefully and set errno to ENOMEM if it doesn't fit in the environment
but apparently isn't.  I believe the environment size is limited by
ARG_MAX on POSIX-like systems, but it's not usually tested by the caller
(which doesn't know how much space is left).

-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author