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

From: Andrey Chernov <ache_at_nagual.pp.ru>
Date: Sat, 14 Jul 2007 21:03:28 +0400
On Sat, Jul 14, 2007 at 10:25:03AM -0500, Sean C. Farley wrote:
> No.  I see it too.  Here are the changes:
> 1. __merge_environ no longer touches environ.  Only __rebuild_environ(),
>    __build_env() and __clean_env() alter environ.
> 2. watchEnviron renamed to intEnviron.
> 3. __rebuild_environ() uses intEnviron when cycling through the
>    environment; it only sets environ.
> 
> This way environ is not changed unless it has at least one name-value
> pair.
> 
> The new patch is here:
> http://www.farley.org/freebsd/tmp/setenv/clearenv/patch2

Ok.

BTW, I see no needs to duplicate code here:

        rtrnVal = __rebuild_environ(envVarsTotal);
        if (rtrnVal == -1) {
                savedErrno = errno;
                __clean_env(true);
                errno = savedErrno;
        }

        return (rtrnVal);

Failure:
        savedErrno = errno;
        __clean_env(true);
        errno = savedErrno;

        return (-1);

instead of simple:

        rtrnVal = __rebuild_environ(envVarsTotal);
        if (rtrnVal == -1)
		goto Failure;

like before in this function.

-- 
http://ache.pp.ru/
Received on Sat Jul 14 2007 - 15:03:31 UTC

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