|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-04-25 23:50 UTC] 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;
}
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
>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