dmitry          Mon Sep 10 10:55:41 2007 UTC

  Modified files:              
    /php-src/sapi/cgi   cgi_main.c 
  Log:
  Fixed bug #42587 (behaviour change regarding symlinked .php files)
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.333&r2=1.334&diff_format=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.333 php-src/sapi/cgi/cgi_main.c:1.334
--- php-src/sapi/cgi/cgi_main.c:1.333   Sat Sep  8 11:10:37 2007
+++ php-src/sapi/cgi/cgi_main.c Mon Sep 10 10:55:41 2007
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: cgi_main.c,v 1.333 2007/09/08 11:10:37 tony2001 Exp $ */
+/* $Id: cgi_main.c,v 1.334 2007/09/10 10:55:41 dmitry Exp $ */
 
 #include "php.h"
 #include "php_globals.h"
@@ -775,6 +775,7 @@
                        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 @@
                         * 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 @@
                                        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 @@
                                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 
*/



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to