Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <55383E43.8010505@skarnet.org>
Date: Thu, 23 Apr 2015 02:35:15 +0200
From: Laurent Bercot <ska-dietlibc@...rnet.org>
To: musl@...ts.openwall.com
Subject: Re: setenv if value=NULL, what say standard? Bug?

On 23/04/2015 02:08, Jean-Marc Pigeon wrote:
> My guess, glibc code is 'blindly" setting the NULL (as "")
> value to the variable.
>
> Is the standard saying otherwise, or do we have a
> a real bug in setenv??

  The standard at
  http://pubs.opengroup.org/onlinepubs/9699919799/functions/setenv.html
  says...

  ... exactly nothing about the possibility of envval being NULL.
This is, in the strictest sense, UB. :)

  Actually, it says "The environment variable shall be set to the value
to which envval points." So, arguably, envval should point to something,
and since NULL does not, it is forbidden. Another valid interpretation
could be that envvar is set to the value to which envval points, i.e.
no value at all, so it is unset; but it doesn't fit the spirit of
setenv() to unset variables. The glibc interpretation, if it does what
you think it does, is wrong in any case: the empty string is a very
different thing from no value at all.

  I think the only safe conclusion is that the application is incorrect
and should ensure that setenv() is never called with a NULL value.

-- 
  Laurent

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.