summaryrefslogtreecommitdiff
path: root/ext/standard/basic_functions.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-06-12 05:07:33 +0400
committerDmitry Stogov <dmitry@zend.com>2014-06-12 05:07:33 +0400
commitdd1c68e67fd5ed5022b62328748fb961d082c070 (patch)
tree8266673f59360ad76297cf0c9e887b531460f3ac /ext/standard/basic_functions.c
parent593b125eb985f5cdfa346d8f1d249924899b2558 (diff)
parentb853f99abfd823fc2752175cab58465cfc8a3eab (diff)
downloadphp-git-dd1c68e67fd5ed5022b62328748fb961d082c070.tar.gz
Merge branch 'master' into phpng
* master: (77 commits) NEWS entry for Fix potential segfault in dns_get_record() NEWS entry for "Fix potential segfault in dns_get_record()" NEWS entry for Fix potential segfault in dns_get_record( Fix potential segfault in dns_get_record() Revert "Add optional second arg to unserialize()" 5.5.15 now update NEWS Fix bug #66127 (Segmentation fault with ArrayObject unset) 5.4.31 next Add NEWS. This doesn't need UPGRADING (or an RFC), IMO. Fix broken test. Add a mime type map generation script and update the header. Move the mime type map out of php_cli_server.c for easier generation. Replace the CLI server's linear search for extensions with a hash table. fix test Remove unused included file NEWS NEWS NEWS Fixed Bug #67413 fileinfo: cdf_read_property_info insufficient boundary chec ... Conflicts: Zend/zend_closures.c Zend/zend_execute.c Zend/zend_vm_def.h Zend/zend_vm_execute.h ext/spl/spl_array.c ext/standard/basic_functions.c ext/standard/dns.c ext/standard/var.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 0242f8aaba..c8b3f96bc5 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)
@@ -4042,92 +4041,91 @@ PHP_FUNCTION(putenv)
{
char *setting;
int 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_str_del(&BG(putenv_ht), pe.key, pe.key_len);
+ zend_hash_str_del(&BG(putenv_ht), pe.key, pe.key_len);
- /* 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_str_add_mem(&BG(putenv_ht), pe.key, pe.key_len, &pe, sizeof(putenv_entry));
+ zend_hash_str_add_mem(&BG(putenv_ht), pe.key, pe.key_len, &pe, sizeof(putenv_entry));
#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