Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Oct 2012 16:10:16 GMT
From:      Andrey Chernov <ache@vniz.net>
To:        freebsd-standards@FreeBSD.org
Subject:   Re: standards/172273: unsetenv(3) issue according to autoconf
Message-ID:  <201210021610.q92GAG5t035278@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR standards/172273; it has been noted by GNATS.

From: Andrey Chernov <ache@vniz.net>
To: Ed Maste <emaste@FreeBSD.org>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: standards/172273: unsetenv(3) issue according to autoconf
Date: Tue, 02 Oct 2012 20:08:31 +0400

 This is a multi-part message in MIME format.
 --------------050703020706000604050704
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 On 02.10.2012 18:41, Ed Maste wrote:
 >> Number:         172273
 >> Category:       standards
 >> Synopsis:       unsetenv(3) issue according to autoconf
 >> Confidential:   no
 >> Severity:       non-critical
 >> Priority:       low
 >> Responsible:    freebsd-standards
 >> State:          open
 >> Quarter:        
 >> Keywords:       
 >> Date-Required:
 >> Class:          sw-bug
 >> Submitter-Id:   current-users
 >> Arrival-Date:   Tue Oct 02 14:50:10 UTC 2012
 >> Closed-Date:
 >> Last-Modified:
 >> Originator:     Ed Maste
 >> Release:        FreeBSD 9.1-PRERELEASE amd64
 >> Organization:
 > FreeBSD
 >> Environment:
 > FreeBSD feynman 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #18 r240994M: Thu Sep 27 09:08:57 EDT 2012     emaste@feynman:/data2/emaste/obj/home/emaste/src/9/sys/TEST  amd64
 > 
 > GNU autoconf's unsetenv test fails on 9.1 - see test case below.
 > 
 > 
 >> Description:
 >> How-To-Repeat:
 > 
 > The autoconf test is reproduced below - the 'return 3' is the failing line
 > 
 > 
 > #include <stdlib.h>
 > #include <errno.h>
 > extern char **environ;
 > 
 > int main(int argc, char *argv[])
 > {
 >        char entry1[] = "a=1";
 >        char entry2[] = "b=2";
 >        char *env[] = { entry1, entry2, NULL };
 >        if (putenv ((char *) "a=1")) return 1;
 >        if (putenv (entry2)) return 2;
 >        entry2[0] = 'a';
 >        unsetenv ("a");
 >        if (getenv ("a")) return 3;
 >        if (!unsetenv ("") || errno != EINVAL) return 4;
 >        entry2[0] = 'b';
 >        environ = env;
 >        if (!getenv ("a")) return 5;
 >        entry2[0] = 'a';
 >        unsetenv ("a");
 >        if (getenv ("a")) return 6;
 >        return 0;
 > }
 > 
 >> Fix:
 > 
 
 Attached simple patch should fix this issue (failing on test 3).
 
 
 
 --------------050703020706000604050704
 Content-Type: text/plain; charset=windows-1251;
  name="getenv.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="getenv.patch"
 
 --- getenv.c.bak	2012-10-02 20:01:33.000000000 +0400
 +++ getenv.c	2012-10-02 20:03:33.000000000 +0400
 @@ -675,7 +675,8 @@
  
  	/* Deactivate specified variable. */
  	envNdx = envVarsTotal - 1;
 -	if (__findenv(name, nameLen, &envNdx, true) != NULL) {
 +	/* Remove all occurences */
 +	while (__findenv(name, nameLen, &envNdx, true) != NULL) {
  		envVars[envNdx].active = false;
  		if (envVars[envNdx].putenv)
  			__remove_putenv(envNdx);
 
 --------------050703020706000604050704--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210021610.q92GAG5t035278>