NetBSD Problem Report #46360
From yamt@NetBSD.org Fri Apr 20 16:58:03 2012
Return-Path: <yamt@NetBSD.org>
Received: by www.NetBSD.org (Postfix, from userid 1270)
id EC89563B86B; Fri, 20 Apr 2012 16:58:02 +0000 (UTC)
Message-Id: <20120420165802.EC89563B86B@www.NetBSD.org>
Date: Fri, 20 Apr 2012 16:58:02 +0000 (UTC)
From: yamt@NetBSD.org
Reply-To: yamt@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: putenv incompatibility
X-Send-Pr-Version: 3.95
>Number: 46360
>Category: lib
>Synopsis: putenv incompatibility
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Apr 20 17:00:00 +0000 2012
>Closed-Date: Sun Sep 09 01:07:14 +0000 2012
>Last-Modified: Sun Sep 09 01:07:14 +0000 2012
>Originator: YAMAMOTO Takashi
>Release: NetBSD current
>Organization:
>Environment:
>Description:
some binaries built on netbsd-5 doesn't work correctly on current
due to the putenv incompatibility.
eg. the following is a snippet from erlang. HAVE_COPYING_PUTENV is
detected by a configure script and is set for netbsd-5.
it's unsafe for current because putenv makes 'str' a part of
environment.
static void
set_env(char *key, char *value)
{
#ifdef __WIN32__
if (!SetEnvironmentVariable((LPCTSTR) key, (LPCTSTR) value))
error("SetEnvironmentVariable(\"%s\", \"%s\") failed!", key, value);
#else
size_t size = strlen(key) + 1 + strlen(value) + 1;
char *str = emalloc(size);
sprintf(str, "%s=%s", key, value);
if (putenv(str) != 0)
error("putenv(\"%s\") failed!", str);
#ifdef HAVE_COPYING_PUTENV
efree(str);
#endif
#endif
}
>How-To-Repeat:
>Fix:
version putenv?
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/46360 CVS commit: src
Date: Fri, 20 Apr 2012 13:31:30 -0400
Module Name: src
Committed By: christos
Date: Fri Apr 20 17:31:30 UTC 2012
Modified Files:
src/include: stdlib.h
src/lib/libc/compat/include: stdlib.h
src/lib/libc/compat/stdlib: Makefile.inc
Added Files:
src/lib/libc/compat/stdlib: compat_putenv.c
Log Message:
PR/46360: YAMAMOTO Takashi: Restore NetBSD-5 compatibility with putenv()
copying the passed string (which is not ToG compliant), instead of using
it directly in the environment arrat as it should. Needs to be pulled up
to NetBSd-6.
To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/include/stdlib.h
cvs rdiff -u -r1.4 -r1.5 src/lib/libc/compat/include/stdlib.h
cvs rdiff -u -r1.2 -r1.3 src/lib/libc/compat/stdlib/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/compat/stdlib/compat_putenv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Jeff Rizzo" <riz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/46360 CVS commit: [netbsd-6] src
Date: Mon, 7 May 2012 16:47:23 +0000
Module Name: src
Committed By: riz
Date: Mon May 7 16:47:23 UTC 2012
Modified Files:
src/include [netbsd-6]: stdlib.h
src/lib/libc/compat/include [netbsd-6]: stdlib.h
src/lib/libc/compat/stdlib [netbsd-6]: Makefile.inc
Added Files:
src/lib/libc/compat/stdlib [netbsd-6]: compat_putenv.c
Log Message:
Pull up following revision(s) (requested by christos in ticket #222):
include/stdlib.h: revision 1.98
lib/libc/compat/stdlib/Makefile.inc: revision 1.3
lib/libc/compat/include/stdlib.h: revision 1.5
lib/libc/compat/stdlib/compat_putenv.c: revision 1.1
lib/libc/compat/stdlib/compat_putenv.c: revision 1.2
PR/46360: YAMAMOTO Takashi: Restore NetBSD-5 compatibility with putenv()
copying the passed string (which is not ToG compliant), instead of using
it directly in the environment arrat as it should. Needs to be pulled up
to NetBSd-6.
use setenv so that we don't leak memory.
To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.97.6.1 src/include/stdlib.h
cvs rdiff -u -r1.4 -r1.4.10.1 src/lib/libc/compat/include/stdlib.h
cvs rdiff -u -r1.2 -r1.2.46.1 src/lib/libc/compat/stdlib/Makefile.inc
cvs rdiff -u -r0 -r1.2.2.2 src/lib/libc/compat/stdlib/compat_putenv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 09 Sep 2012 01:07:14 +0000
State-Changed-Why:
fixed in april, pulled up in may
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.