#41446 [Opn->Fbk]: Incorrect PATH_INFO when just '/' is specified

From: Date: Mon, 21 May 2007 16:41:23 +0000
Subject: #41446 [Opn->Fbk]: Incorrect PATH_INFO when just '/' is specified
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112910@lists.php.net to get a copy of this message
ID: 41446 Updated by: iliaa@php.net Reported By: robertn at the-nelsons dot org -Status: Open +Status: Feedback Bug Type: CGI related Operating System: Linux PHP Version: 5.2.2 New Comment: I've tried to reproduce the problem, but it seems to be working fine as is. Can you show me output of $_SERVER from a working path info request? Previous Comments: ------------------------------------------------------------------------ [2007-05-20 22:46:06] robertn at the-nelsons dot org Apache/2.0.54 (Unix) PHP/4.4.4 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_fastcgi/2.4.2 DAV/2 SVN/1.4.2 ------------------------------------------------------------------------ [2007-05-20 16:06:10] iliaa@php.net What web server are you using? ------------------------------------------------------------------------ [2007-05-20 02:09:25] robertn at the-nelsons dot org This bug happens because tsrm_realpath() strips any trailing slashes before resolving the realpath. The fix is to change the code in sapi/cgi/cgi_main.c at line 799. From: if (script_path_translated && (real_path = tsrm_realpath(script_path_translated, NULL TSRMLS_CC)) == NULL) { to: if (script_path_translated && (script_path_translated[strlen(script_path_translated) - 1] == '/' || script_path_translated[strlen(script_path_translated) - 1] == '\\' || (real_path = tsrm_realpath(script_path_translated, NULL TSRMLS_CC)) == NULL)) { This isn't the most efficient fix but best illustrates the solution. ------------------------------------------------------------------------ [2007-05-20 01:27:15] robertn at the-nelsons dot org Description: ------------ If the path info contains just a slash then php returns the "No input file specified." error. Reproduce code: --------------- 1) create a phpinfo.php file with "<?php print phpinfo(); ?>" 2) View the page in the browser to make sure it works. 3) Append a / to the url and view the page again. A 404 error with the "No input file specified." is returned. 4) Append a /x to the original url and view the page again. This time it works and PATH_INFO is correctly set to "/x". Expected result: ---------------- If just a "/" is specified then PATH_INFO should be "/" Actual result: -------------- 404 No input file specified ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41446&edit=1

« previous php.bugs (#112910) next »