]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #44836 (putenv() crashes, avoid direct reference of environ
authorIlia Alshanetsky <iliaa@php.net>
Tue, 6 May 2008 18:03:52 +0000 (18:03 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 6 May 2008 18:03:52 +0000 (18:03 +0000)
in POSIX systems).

NEWS
ext/standard/basic_functions.c

diff --git a/NEWS b/NEWS
index 30865878bf4ad48c3b2f66d4a1c5b931bb71a7ba..877f87e169e800dd6fbbe4e2a5087094b21965c6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,8 +5,11 @@ PHP                                                                        NEWS
   functions. (Andrey)
 - Fixed bug #44891 Memory leak using registerPHPFunctions and XSLT Variable 
   as function parameter. (Rob)
+- Fixed bug #44836 (putenv() crashes, avoid direct reference of environ in    
+  POSIX systems). (Ilia, delphij at FreeBSD dot org)
 - Fixed bug #44798 (Memory leak assigning value to attribute). (Ilia)
 
+
 01 May 2008, PHP 5.2.6
 - Fixed two possible crashes inside posix extension (Tony)
 - Fixed incorrect heredoc handling when label is used within the block. 
index cec0b1f636c4289a48d193ad94cdde07574e1559..330f717c694ddab7e26843f9cf41bf76301fb608 100644 (file)
@@ -3859,9 +3859,7 @@ static void php_putenv_destructor(putenv_entry *pe)
                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);
@@ -4461,12 +4459,8 @@ PHP_FUNCTION(putenv)
                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 */
+                               /* must copy previous value because putenv can free the string without notice */
                                pe.previous_value = estrdup(*env);
-#else
-                               pe.previous_value = *env;
-#endif
                                break;
                        }
                }