summaryrefslogtreecommitdiff
path: root/ext/standard/basic_functions.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-07-01 09:10:36 +0200
committerAnatol Belski <ab@php.net>2014-07-01 09:10:36 +0200
commit1a50c27f998769c5b3472d35c39852286900db69 (patch)
tree3c83075a87d566d3d2cac23523ce3f737805aa32 /ext/standard/basic_functions.c
parentd4cfc15514285d42f113facc1c296d32a818ccf2 (diff)
parent2330be5641c907b7edd7cffdd3074e85d0091df5 (diff)
downloadphp-git-1a50c27f998769c5b3472d35c39852286900db69.tar.gz
Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport
* origin/PHP-5.6: (170 commits) 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 Fixed issue krakjoe/phpdbg#94 - List behavior is inconsistent Fix issue krakjoe/phpdbg#97 - list now appends a newline if there is none The prompt should always ensure it is on a newline Fixed test Inform about back command existence in help - Fixes krakjoe/phpdbg#100 No way to list the current stack/frames Fix issue krakjoe/phpdbg#98 break if does not seem to work Fix issue krakjoe/phpdbg#99 register function has the same behavior as run Fix readline/libedit (Thanks to @remicollet) Replace incorrect `E` command with `ev` in watch help ... Conflicts: Zend/zend_compile.c ext/standard/basic_functions.c ext/standard/http_fopen_wrapper.c ext/standard/var.c ext/tokenizer/tokenizer_data.c sapi/phpdbg/phpdbg_list.c
Diffstat (limited to 'ext/standard/basic_functions.c')
-rw-r--r--ext/standard/basic_functions.c112
1 files changed, 55 insertions, 57 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index ec86c3ccd9..b9d216a2d5 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -2648,7 +2648,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)
@@ -4044,92 +4043,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