From: Xinchen Hui <laruence@gmail.com>
Date: Mon, 21 Sep 2015 03:18:37 +0000 (+0800)
Subject: Fixed bug #70538 ("php-fpm -i" crashes)
X-Git-Tag: php-7.1.0alpha1~1143^2
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85eece9c4fab08cc73f09f5bb67c3a2752b746b2;p=php

Fixed bug #70538 ("php-fpm -i" crashes)
---

diff --git a/NEWS b/NEWS
index b62d856143..3d8abc9d9a 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,10 @@ PHP                                                                        NEWS
   . Fixed bug #70481 (Memory leak in auto_global_copy_ctor() in ZTS build).
     (Laruence)
 
+- FPM:
+  . Fixed bug #70538 ("php-fpm -i" crashes). (rainer dot jung at
+    kippdata dot de)
+
 - OpenSSL
   . Require at least OpenSSL version 0.9.8. (Jakub Zelenka)
 
diff --git a/sapi/fpm/fpm/fpm_main.c b/sapi/fpm/fpm/fpm_main.c
index 18f8a908db..ca478b31f3 100644
--- a/sapi/fpm/fpm/fpm_main.c
+++ b/sapi/fpm/fpm/fpm_main.c
@@ -589,7 +589,6 @@ void cgi_php_import_environment_variables(zval *array_ptr) /* {{{ */
 
 static void sapi_cgi_register_variables(zval *track_vars_array) /* {{{ */
 {
-	fcgi_request *request = (fcgi_request*) SG(server_context);
 	size_t php_self_len;
 	char *php_self;
 
@@ -601,7 +600,7 @@ static void sapi_cgi_register_variables(zval *track_vars_array) /* {{{ */
 	if (CGIG(fix_pathinfo)) {
 		char *script_name = SG(request_info).request_uri;
 		unsigned int script_name_len = script_name ? strlen(script_name) : 0;
-		char *path_info = request? FCGI_GETENV(request, "PATH_INFO") : NULL;
+		char *path_info = sapi_cgibin_getenv("PATH_INFO", sizeof("PATH_INFO") - 1);
 		unsigned int path_info_len = path_info ? strlen(path_info) : 0;
 
 		php_self_len = script_name_len + path_info_len;