summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2007-09-10 10:55:41 +0000
committerDmitry Stogov <dmitry@php.net>2007-09-10 10:55:41 +0000
commitc49d25c642517b1f48c0ad0824eea011b40ff402 (patch)
tree16d2180e3d37cdc45a2e63dd3a2fa621c394dc3e
parent1d42952da92fa22c12069e7f8ef9b15feeb04eec (diff)
downloadphp-git-c49d25c642517b1f48c0ad0824eea011b40ff402.tar.gz
Fixed bug #42587 (behaviour change regarding symlinked .php files)
-rw-r--r--sapi/cgi/cgi_main.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 2cba3a5d60..6950443f83 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -775,6 +775,7 @@ static void init_request_info(TSRMLS_D)
char *orig_path_info = env_path_info;
char *orig_script_name = env_script_name;
char *orig_script_filename = env_script_filename;
+ int script_path_translated_len;
if (!env_document_root && PG(doc_root)) {
env_document_root = _sapi_cgibin_putenv("DOCUMENT_ROOT", PG(doc_root) TSRMLS_CC);
@@ -805,9 +806,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, '\\'))) {
@@ -947,9 +950,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 &&
@@ -982,9 +982,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 {
/* pre 4.3 behaviour, shouldn't be used but provides BC */