]> granicus.if.org Git - php/commitdiff
Fixed bug #42587 (behaviour change regarding symlinked .php files)
authorDmitry Stogov <dmitry@php.net>
Mon, 10 Sep 2007 10:55:26 +0000 (10:55 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 10 Sep 2007 10:55:26 +0000 (10:55 +0000)
NEWS
sapi/cgi/cgi_main.c

diff --git a/NEWS b/NEWS
index 60010c0474cff61bd100dd4b042075e86c1ef169..81835b104ea0cc2e7061c1ec4f998b350230abd3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ PHP                                                                        NEWS
 
 - Fixed bug #42590 (Make the engine recornize \v and \f escape sequences). 
   (Ilia)
+- Fixed bug #42587 (behaviour change regarding symlinked .php files). (Dmitry)
 - Fixed bug #42579 (apache_reset_timeout() does not exist). (Jani)
 - Fixed bug #42549 (ext/mysql failed to compile with libmysql 3.23). (Scott)
 - Fixed bug #42523 (PHP_SELF duplicates path). (Dmitry)
index 9034479997b7d36bbf36b30d54361844fc69f927..21451cb0e689c887bd7f500de01374afb84d3eb8 100644 (file)
@@ -777,6 +777,7 @@ static void init_request_info(TSRMLS_D)
                struct stat st;
                char *env_redirect_url = sapi_cgibin_getenv("REDIRECT_URL", sizeof("REDIRECT_URL")-1 TSRMLS_CC);
                char *env_document_root = sapi_cgibin_getenv("DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC);
+               int script_path_translated_len;
 
                /* Hack for buggy IIS that sets incorrect PATH_INFO */
                char *env_server_software = sapi_cgibin_getenv("SERVER_SOFTWARE", sizeof("SERVER_SOFTWARE")-1 TSRMLS_CC);
@@ -829,9 +830,11 @@ static void init_request_info(TSRMLS_D)
                         * this fixes url's like /info.php/test
                         */
                        if (script_path_translated &&
-                           (real_path = tsrm_realpath(script_path_translated, NULL TSRMLS_CC)) == NULL) {
-                               char *pt = estrdup(script_path_translated);
-                               int len = strlen(pt);
+                               (script_path_translated_len = strlen(script_path_translated)) > 0 &&
+                               (script_path_translated[script_path_translated_len-1] == '/' ||
+                            (real_path = tsrm_realpath(script_path_translated, NULL TSRMLS_CC)) == NULL)) {
+                               char *pt = estrndup(script_path_translated, script_path_translated_len);
+                               int len = script_path_translated_len;
                                char *ptr;
 
                                while ((ptr = strrchr(pt, '/')) || (ptr = strrchr(pt, '\\'))) {
@@ -971,9 +974,6 @@ static void init_request_info(TSRMLS_D)
                                        SG(request_info).path_translated = estrdup(script_path_translated);
                                }
                        } else {
-                               if (real_path) {
-                                       script_path_translated = real_path;
-                               }
                                /* make sure path_info/translated are empty */
                                if (!orig_script_filename ||
                                        (script_path_translated != orig_script_filename &&
@@ -1006,9 +1006,7 @@ static void init_request_info(TSRMLS_D)
                                if (script_path_translated && !strstr(script_path_translated, "..")) {
                                        SG(request_info).path_translated = estrdup(script_path_translated);
                                }
-                               if (real_path) {
-                                       free(real_path);
-                               }
+                               free(real_path);
                        }
                } else {
 #endif