This is the mail archive of the
mailing list for the glibc project.
Re: [patch] Error on setenv(..., NULL, ...)
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>, Paul Pluzhnikov <ppluzhnikov at google dot com>
- Cc: GLIBC Devel <libc-alpha at sourceware dot org>
- Date: Wed, 11 Mar 2015 16:38:09 +0000
- Subject: Re: [patch] Error on setenv(..., NULL, ...)
- Authentication-results: sourceware.org; auth=none
- References: <CALoOobNSbWUkd_i-L6U0ovbqPYnJY-h=ftX1K61yb19pmJj6aw at mail dot gmail dot com> <20150311163327 dot GV9714 at spoyarek dot pnq dot redhat dot com>
On 11/03/15 16:33, Siddhesh Poyarekar wrote:
> On Wed, Mar 11, 2015 at 09:11:59AM -0700, Paul Pluzhnikov wrote:
>> Attached trivial patch makes setenv(..., NULL, ...) fail instead of
>> producing "bad" environment. Tested on Linux/x86_64, no new failures.
> The standard says:
> "The environment variable shall be set to the value to which envval points"
> and is vague since it could be interpreted in one of two ways:
no, this just says that NULL argument is undefined behaviour
this is not a bug in glibc and i don't think any change should be made
> 1. setenv (..., NULL, ...) is equivalent to unsetting the environment
> variable, since getenv(...) would return NULL.
> 2. setenv (..., NULL, ...) is equivalent to setenv (..., "", ...),
> resulting in getenv returning a blank value.
> Making it fail would be incorrect since it could break programs that
> did not previously expect a failure from an invalid value and will
> also not conform to the standard since the standard does not specify
> such a failure. While Option 1 seems closer to the above statement to
> me, Option 2 seems like a safer fix.
>  http://pubs.opengroup.org/onlinepubs/9699919799/functions/setenv.html