com php-src: Allow creating $_SERVER from $_ENV, but not $_ENV from $_SERVER.: sapi/cgi /cgi_main.c

From: Date: Mon, 13 Nov 2017 15:24:43 +0000
Subject: com php-src: Allow creating $_SERVER from $_ENV, but not $_ENV from $_SERVER.: sapi/cgi /cgi_main.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-100209@lists.php.net to get a copy of this message
Commit: bdf77f02f637bc0efbb55a800be1860279cc5b3e Author: Dmitry Stogov <dmitry@zend.com> Mon, 13 Nov 2017 18:24:43 +0300 Parents: 275bba2b7eb7d5f1d913f44fe8024bccb784e6c6 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bdf77f02f637bc0efbb55a800be1860279cc5b3e Log: Allow creating $_SERVER from $_ENV, but not $_ENV from $_SERVER. Changed paths: M sapi/cgi/cgi_main.c Diff: diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 8639027..27f45f9 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -624,20 +624,15 @@ static void cgi_php_load_env_var(char *var, unsigned int var_len, char *val, uns static void cgi_php_import_environment_variables(zval *array_ptr) { + if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) != IS_ARRAY) { + zend_is_auto_global_str("_ENV", sizeof("_ENV")-1); + } + if (Z_TYPE(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && - Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV]) && - zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_ENV])) > 0 - ) { + Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_ENV])) { zval_dtor(array_ptr); ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_ENV]); return; - } else if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && - Z_ARR_P(array_ptr) != Z_ARR(PG(http_globals)[TRACK_VARS_SERVER]) && - zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER])) > 0 - ) { - zval_dtor(array_ptr); - ZVAL_DUP(array_ptr, &PG(http_globals)[TRACK_VARS_SERVER]); - return; } /* call php's original import as a catch-all */ @@ -1983,6 +1978,11 @@ consult the installation file that came with this distribution, or visit \n\ } fastcgi = fcgi_is_fastcgi(); } + + /* make php call us to get _ENV vars */ + php_php_import_environment_variables = php_import_environment_variables; + php_import_environment_variables = cgi_php_import_environment_variables; + if (fastcgi) { /* How many times to run PHP scripts before dying */ if (getenv("PHP_FCGI_MAX_REQUESTS")) { @@ -1993,10 +1993,6 @@ consult the installation file that came with this distribution, or visit \n\ } } - /* make php call us to get _ENV vars */ - php_php_import_environment_variables = php_import_environment_variables; - php_import_environment_variables = cgi_php_import_environment_variables; - /* library is already initialized, now init our request */ request = fcgi_init_request(fcgi_fd, NULL, NULL, NULL);

« previous php.cvs (#100209) next »