diff options
author | Anatol Belski <ab@php.net> | 2014-07-02 10:27:59 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-07-02 10:27:59 +0200 |
commit | 84876850ff3e50ee7b85abc7261bdf9038d65e4b (patch) | |
tree | 091e7474679a1b6700459d6db2e36e0ac9272397 /ext/standard/basic_functions.c | |
parent | 0e7bf92129f608c44f4d5bd51139ec2bd85fecc8 (diff) | |
parent | 96783bdfb79b33646dc916d4b93bc33b78d70c4c (diff) | |
download | php-git-84876850ff3e50ee7b85abc7261bdf9038d65e4b.tar.gz |
Merge remote-tracking branch 'origin/str_size_and_int64_56_backport' into str_size_and_int64
* origin/str_size_and_int64_56_backport: (178 commits)
fix integer overflow in {stream,file}_{get,put}_contents()
add some missing NEWS entries
NEWS block for 5.6.0RC3
Fix ext/pgsql builds with libpq < 7.3.
updated libs_version.txt
updated libs_version.txt
updated libmagic.patch in 5.6+
updated libmagic.patch
Fixed possible crash because of race conditions on modifying constants in shared memory
remove the NEWS entry for the reverted fpm fix
remove the NEWS entry for the reverted fpm fix
remove the NEWS entry for the reverted fpm fix
Revert "Fix Bug #67530 error_log=syslog ignored"
--enable-fpm for the travis build
fix the last fpm NEWS entry, the other bug is related, but not the same what we fixed here
NEWS
NEWS
Fix bug #67091: make install fails to install libphp5.so on FreeBSD 10.0
adding NEWS entry for the fix for bug #65641
Updated NEWS file for recent phpdbg fixes
...
Diffstat (limited to 'ext/standard/basic_functions.c')
-rw-r--r-- | ext/standard/basic_functions.c | 112 |
1 files changed, 55 insertions, 57 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 545df51661..5b37f620a2 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2636,7 +2636,6 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_unserialize, 0, 0, 1) ZEND_ARG_INFO(0, variable_representation) - ZEND_ARG_INFO(1, consumed) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_memory_get_usage, 0, 0, 0) @@ -4030,92 +4029,91 @@ PHP_FUNCTION(putenv) { char *setting; php_size_t setting_len; + char *p, **env; + putenv_entry pe; +#ifdef PHP_WIN32 + char *value = NULL; + int equals = 0; + int error_code; +#endif if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &setting, &setting_len) == FAILURE) { return; } + + if(setting_len == 0 || setting[0] == '=') { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter syntax"); + RETURN_FALSE; + } - if (setting_len) { - char *p, **env; - putenv_entry pe; + pe.putenv_string = estrndup(setting, setting_len); + pe.key = estrndup(setting, setting_len); + if ((p = strchr(pe.key, '='))) { /* nullify the '=' if there is one */ + *p = '\0'; #ifdef PHP_WIN32 - char *value = NULL; - int equals = 0; - int error_code; + equals = 1; #endif + } - pe.putenv_string = estrndup(setting, setting_len); - pe.key = estrndup(setting, setting_len); - if ((p = strchr(pe.key, '='))) { /* nullify the '=' if there is one */ - *p = '\0'; -#ifdef PHP_WIN32 - equals = 1; -#endif - } - - pe.key_len = strlen(pe.key); + pe.key_len = strlen(pe.key); #ifdef PHP_WIN32 - if (equals) { - if (pe.key_len < setting_len - 1) { - value = p + 1; - } else { - /* empty string*/ - value = p; - } + if (equals) { + if (pe.key_len < setting_len - 1) { + value = p + 1; + } else { + /* empty string*/ + value = p; } + } #endif - zend_hash_del(&BG(putenv_ht), pe.key, pe.key_len+1); + zend_hash_del(&BG(putenv_ht), pe.key, pe.key_len+1); - /* find previous value */ - 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 */ + /* find previous value */ + 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); + /* must copy previous value because MSVCRT's putenv can free the string without notice */ + pe.previous_value = estrdup(*env); #else - pe.previous_value = *env; + pe.previous_value = *env; #endif - break; - } + break; } + } #if HAVE_UNSETENV - if (!p) { /* no '=' means we want to unset it */ - unsetenv(pe.putenv_string); - } - if (!p || putenv(pe.putenv_string) == 0) { /* success */ + if (!p) { /* no '=' means we want to unset it */ + unsetenv(pe.putenv_string); + } + if (!p || putenv(pe.putenv_string) == 0) { /* success */ #else # ifndef PHP_WIN32 - if (putenv(pe.putenv_string) == 0) { /* success */ + if (putenv(pe.putenv_string) == 0) { /* success */ # else - error_code = SetEnvironmentVariable(pe.key, value); + error_code = SetEnvironmentVariable(pe.key, value); # if _MSC_VER < 1500 - /* Yet another VC6 bug, unset may return env not found */ - if (error_code != 0 || - (error_code == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)) { + /* Yet another VC6 bug, unset may return env not found */ + if (error_code != 0 || + (error_code == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)) { # else - if (error_code != 0) { /* success */ + if (error_code != 0) { /* success */ # endif # endif #endif - zend_hash_add(&BG(putenv_ht), pe.key, pe.key_len + 1, (void **) &pe, sizeof(putenv_entry), NULL); + zend_hash_add(&BG(putenv_ht), pe.key, pe.key_len + 1, (void **) &pe, sizeof(putenv_entry), NULL); #ifdef HAVE_TZSET - if (!strncmp(pe.key, "TZ", pe.key_len)) { - tzset(); - } -#endif - RETURN_TRUE; - } else { - efree(pe.putenv_string); - efree(pe.key); - RETURN_FALSE; + if (!strncmp(pe.key, "TZ", pe.key_len)) { + tzset(); } +#endif + RETURN_TRUE; + } else { + efree(pe.putenv_string); + efree(pe.key); + RETURN_FALSE; } - - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter syntax"); - RETURN_FALSE; } /* }}} */ #endif |