Index | Thread | Search

From:
"Theo de Raadt" <deraadt@openbsd.org>
Subject:
Re: setenv(3) segfaults when value == NULL
To:
enh <enh@google.com>
Cc:
"Lyndon Nerenberg (VE7TFX/VE6BBM)" <lyndon@orthanc.ca>, tech@openbsd.org
Date:
Fri, 13 Mar 2026 16:20:29 -0600

Download raw body.

Thread
enh <enh@google.com> wrote:

> might be worth filing an austin group bug, since their ERRORS section
> only mentions name:
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/setenv.html
> 
> (leaving it unclear just how an implementation can "copy" a null
> string... that strlen() being the point at which all the
> implementations i just checked currently crash :-) )
> 
> On Fri, Mar 13, 2026 at 4:45 PM Lyndon Nerenberg (VE7TFX/VE6BBM)
> <lyndon@orthanc.ca> wrote:
> >
> > Calling setenv(3) as setenv("foo", NULL, 1) will SEGV.  This
> > should return EINVAL as with setenv(NULL, "foo", 1).

Furthermore I disagree with this trend to "always return an error
vaue".

An example is fclose(NULL).

That crashes.  It *SHOULD* crash, so that you can find and fix the bug.