GNU bug report logs - #13070
Use putenv+unsetenv instead of modifying environ directly

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Mon, 3 Dec 2012 20:37:01 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #25 received at 13070 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 13070 <at> debbugs.gnu.org, fabrice.popineau <at> gmail.com
Subject: Re: Use putenv+unsetenv instead of modifying environ directly
Date: Sat, 08 Dec 2012 20:31:18 +0200
> Date: Sat, 08 Dec 2012 09:20:57 -0800
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> CC: fabrice.popineau <at> gmail.com, 13070-done <at> debbugs.gnu.org
> 
> On 12/08/2012 03:42 AM, Eli Zaretskii wrote:
> > Shouldn't we refrain from signaling memory_full when errno is EINVAL?
> > I'd suggest an eassert in that case.  memory_full will emit a
> > misleading diagnostic.
> 
> errno cannot be EINVAL, at least not on a POSIXish host:
> all strings are allowed as arguments to putenv.

What about NULL pointers?  Or strings without a '='?  IMO, it's silly
to rely on unspecified behavior, but suit yourself.

> I did see a minor problem in the w32.c implementation of unsetenv:
> 
>   /* MS docs says an environment variable cannot be longer than 32K.  */
>   if (name_len > 32767)
>     {
>       errno = ENOMEM;
>       return -1;
>     }
> 
> unsetenv should return 0 in that case, not -1, since
> the variable cannot possibly be in the environment.

Right, I fixed that.




This bug report was last modified 12 years and 226 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.