#44836 [Asn]: [PATCH] putenv() crashes, avoid direct reference of environ in POSIX systems
by tony2001 other posts by this author
May 8 2008 12:49AM messages near this date
#44836 [Asn]: [PATCH] putenv() crashes, avoid direct reference of environ in POSIX systems
|
#44836 [Com]: [PATCH] putenv() crashes, avoid direct reference of environ in POSIX systems
ID: 44836
Updated by: tony2001@[...].net
Reported By: delphij at FreeBSD dot org
Status: Assigned
Bug Type: Reproducible crash
Operating System: FreeBSD 7.0
PHP Version: 5.2.5
Assigned To: iliaa
New Comment:
> Which glibc version are you using?
Reproducible with both glibc 2.5 (openSuSE 10.2 64bit) and 2.6.1
(openSuSE 10.3 64bit).
In order to reproduce it you need to run this:
TEST_VAR1=test TEST_VAR2=test valgrind --tool=memcheck ./sapi/cli/php
-r 'putenv("TEST_VAR1"); putenv("TEST_VAR2");'
> Do you have backtraces?
Valgrind log is here: http://news.php.net/php.cvs/49863
Previous Comments:
------------------------------------------------------------------------
[2008-05-07 21:54:35] rachid at dnsregistraties dot nl
The patch on 5.2.6 for posix is causing crash on the linux versions. Is
it possible to fix this soon?
------------------------------------------------------------------------
[2008-05-07 08:42:58] tony2001@[...].net
Your patch causes crashes on Linux, please revert.
------------------------------------------------------------------------
[2008-05-06 18:04:30] iliaa@[...].net
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2008-04-25 23:50:49] delphij at FreeBSD dot org
Description:
------------
PHP would crash in certain cases where putenv() is being called, in
POSIX systems which calls free() in putenv().
The following patch always duplicate the environment from the
environment instead of relying on that they are invariant.
--- ext/standard/basic_functions.c.orig 2008-04-25 16:26:14.885468614
-0700
+++ ext/standard/basic_functions.c 2008-04-25 16:32:46.215744075 -0700
@@ -3861,9 +3862,7 @@
SetEnvironmentVariable(pe-> key, "bugbug");
#endif
putenv(pe-> previous_value);
-# if defined(PHP_WIN32)
efree(pe-> previous_value);
-# endif
} else {
# if HAVE_UNSETENV
unsetenv(pe-> key);
@@ -4463,12 +4462,8 @@
pe.previous_value = NULL;
for (env = environ; env != NULL && *env != NULL; env++) {
if (!strncmp(*env, pe.key, pe.key_len) && (*env)[pe.key_len] ==
'=') { /* found it */
-#if defined(PHP_WIN32)
/* must copy previous value because MSVCRT's putenv can free the
string without notice */
pe.previous_value = estrdup(*env);
-#else
- pe.previous_value = *env;
-#endif
break;
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44836&edit=1
Thread:
delphij at FreeBSD dot org
tony2001
tony2001
tony2001
tony2001
tony2001
Rachid At Dnsregistraties Dot Nl
tony2001
tony2001
iliaa
|