This is the mail archive of the 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] Error on setenv(..., NULL, ...)

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[1]:

"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:

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.



Attachment: pgpOZccuDCZ28.pgp
Description: PGP signature

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