From 07b8d051fa9565bf07a1c408e3f467c1243b9ec7 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 24 May 2006 07:55:19 +0000 Subject: [PATCH] Fixed bug #37341 ($_SERVER in included file is shortened to two entries, if $_ENV gets used). --- NEWS | 2 ++ sapi/cgi/cgi_main.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index ca88662636..722f3beda2 100644 --- a/NEWS +++ b/NEWS @@ -67,6 +67,8 @@ PHP NEWS - Fixed bug #37376 (fastcgi.c compile fail with gcc 2.95.4). (Ilia) - Fixed bug #37368 (Incorrect timestamp returned for strtotime()). (Derick) - Fixed bug #37348 (make PEAR install ignore open_basedir). (Ilia) +- Fixed bug #37341 ($_SERVER in included file is shortened to two entries, + if $_ENV gets used). (Dmitry) - Fixed bug #37313 (sigemptyset() used without including ). (jdolecek) - Fixed bug #37306 (max_execution_time = max_input_time). (Dmitry) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 9b0f12c8a9..1c13747214 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -434,14 +434,18 @@ static char *sapi_cgi_read_cookies(TSRMLS_D) void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC) { if (PG(http_globals)[TRACK_VARS_ENV] && - array_ptr != PG(http_globals)[TRACK_VARS_ENV]) { + array_ptr != PG(http_globals)[TRACK_VARS_ENV] && + Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY && + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) > 0) { zval_dtor(array_ptr); *array_ptr = *PG(http_globals)[TRACK_VARS_ENV]; INIT_PZVAL(array_ptr); zval_copy_ctor(array_ptr); return; } else if (PG(http_globals)[TRACK_VARS_SERVER] && - array_ptr != PG(http_globals)[TRACK_VARS_SERVER]) { + array_ptr != PG(http_globals)[TRACK_VARS_SERVER] && + Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY && + zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) > 0) { zval_dtor(array_ptr); *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER]; INIT_PZVAL(array_ptr); -- 2.50.1