Re: Environment handling broken in /bin/sh with changes to {get,set,put}env()

From: Andrey Chernov <ache_at_nagual.pp.ru>
Date: Sat, 14 Jul 2007 00:39:15 +0400
On Sat, Jul 14, 2007 at 12:24:33AM +0400, Andrey Chernov wrote:
> 1) I care in first hand about unsetenv() as my example states. There 
> nowhere said in the specs that unsetenv() may modify environ _content_, 
> manpage says about pointers only.

Moreover, they directly states (at least for some cases) that environment 
should be left completely untouched, like that:

"If the named variable does not exist in the current environment, the 
environment shall be unchanged and the function is considered to have 
completed successfully."

> 2) That example not fail under FreeBSD 6 but fail under new code:
> 
> nenv[0] = "PATH=/bin";
> nenv[1] = NULL;
> environ = nenv;
> setenv("HOME", "/xxx", 1);

Similar thing to the setenv example: 

nenv[0] = "PATH=/bin";
setenv("PATH", "/bin", 0);

"If the environment variable named by envname already exists and the value 
of overwrite is zero, the function shall return success and the 
environment shall remain unchanged."

-- 
http://ache.pp.ru/
Received on Fri Jul 13 2007 - 18:39:17 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:14 UTC