Received: from esessmw0247.eemea.ericsson.se (153.88.115.93) by ESESSHC005.ericsson.se (153.88.183.33) with Microsoft SMTP Server (TLS) id 14.2.318.4; Mon, 18 Mar 2013 03:32:29 +0100 Received: from mailhost.ac.de.eu.ericsson.se (153.88.115.8) by esessmw0247.eemea.ericsson.se (153.88.115.94) with Microsoft SMTP Server id 8.3.279.1; Mon, 18 Mar 2013 03:32:20 +0100 Received: from linux.local (edeacts0001.ac.de.eu.ericsson.se [137.58.120.16]) by mailhost.ac.de.eu.ericsson.se (Postfix) with ESMTP id C77DB18006C for <Markus.Jansen@ericsson.com>; Mon, 18 Mar 2013 03:32:19 +0100 (CET) Received: by linux.local (Postfix, from userid 16116) id BFDCB3CC751; Mon, 18 Mar 2013 03:32:19 +0100 (CET) From: Markus Jansen <markus.jansen@ericsson.com> To: Markus Jansen <markus.jansen@ericsson.com> CC: Markus Jansen <markus.jansen@ericsson.com> Subject: [PATCH] Fixed PERL_USE_SAFE_PUTENV unsetenv buffer size computation and an issue with unsetenv producing a segmentation violation on a clearenv'd environ (Linux 2.16 with GCC 4.1.2). Thread-Topic: [PATCH] Fixed PERL_USE_SAFE_PUTENV unsetenv buffer size computation and an issue with unsetenv producing a segmentation violation on a clearenv'd environ (Linux 2.16 with GCC 4.1.2). Thread-Index: AQHOI4DWa3WdryHGREyJ10LCXSxB7A== Date: Mon, 18 Mar 2013 02:32:10 +0000 Message-ID: <1363573930-2693-1-git-send-email-markus.jansen@ericsson.com> Content-Language: en-US X-MS-Exchange-Organization-AuthMechanism: 10 X-MS-Exchange-Organization-AuthSource: esessmw0247.eemea.ericsson.se X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 --- util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index 2c745bf..900d729 100644 --- a/util.c +++ b/util.c @@ -1949,7 +1949,9 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val= ) # else # if defined(HAS_UNSETENV) if (val =3D=3D NULL) { - (void)unsetenv(nam); + if (environ !=3D NULL) { /* avoid possible segfault */ + (void)unsetenv(nam); + } } else { const int nlen =3D strlen(nam); const int vlen =3D strlen(val); @@ -6099,6 +6101,7 @@ Perl_my_clearenv(pTHX) if (bsiz < l + 1) { (void)safesysfree(buf); bsiz =3D l + 1; /* + 1 for the \0. */ + bufsiz =3D bsiz * sizeof(char); /* keep bsiz and bufsiz in sync */ buf =3D (char*)safesysmalloc(bufsiz); } memcpy(buf, *environ, l); -- 1.8.1.5Thread Previous