From: Dmitry Stogov Date: Mon, 10 Sep 2007 10:55:26 +0000 (+0000) Subject: Fixed bug #42587 (behaviour change regarding symlinked .php files) X-Git-Tag: php-5.2.5RC1~185 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=96810f0ae60289b876ffbe8c39680910d6e82b1e;p=php Fixed bug #42587 (behaviour change regarding symlinked .php files) --- diff --git a/NEWS b/NEWS index 60010c0474..81835b104e 100644 --- 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) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 9034479997..21451cb0e6 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -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