mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
Fixed bug #44836 (putenv() crashes, avoid direct reference of environ in
POSIX systems) # Original patch by delphij at FreeBSD dot org
This commit is contained in:
parent
259b652b2e
commit
f5a90feff0
1 changed files with 1 additions and 7 deletions
|
@ -3820,9 +3820,7 @@ static void php_putenv_destructor(putenv_entry *pe) /* {{{ */
|
||||||
SetEnvironmentVariable(pe->key, "bugbug");
|
SetEnvironmentVariable(pe->key, "bugbug");
|
||||||
#endif
|
#endif
|
||||||
putenv(pe->previous_value);
|
putenv(pe->previous_value);
|
||||||
# if defined(PHP_WIN32)
|
|
||||||
efree(pe->previous_value);
|
efree(pe->previous_value);
|
||||||
# endif
|
|
||||||
} else {
|
} else {
|
||||||
# if HAVE_UNSETENV
|
# if HAVE_UNSETENV
|
||||||
unsetenv(pe->key);
|
unsetenv(pe->key);
|
||||||
|
@ -4427,12 +4425,8 @@ PHP_FUNCTION(putenv)
|
||||||
pe.previous_value = NULL;
|
pe.previous_value = NULL;
|
||||||
for (env = environ; env != NULL && *env != NULL; env++) {
|
for (env = environ; env != NULL && *env != NULL; env++) {
|
||||||
if (!strncmp(*env, pe.key, pe.key_len) && (*env)[pe.key_len] == '=') { /* found it */
|
if (!strncmp(*env, pe.key, pe.key_len) && (*env)[pe.key_len] == '=') { /* found it */
|
||||||
#if defined(PHP_WIN32)
|
/* must copy previous value because putenv can free the string without notice */
|
||||||
/* must copy previous value because MSVCRT's putenv can free the string without notice */
|
|
||||||
pe.previous_value = estrdup(*env);
|
pe.previous_value = estrdup(*env);
|
||||||
#else
|
|
||||||
pe.previous_value = *env;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue