|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #20226 can't do "foo.php/path.inf" via cgi (with patch)
Submitted: 2002-11-03 05:36 UTC Modified: 2013-02-18 00:04 UTC
From: tom at tomclegg dot net Assigned:
Status: No Feedback Package: CGI/CLI related
PHP Version: 4.2.3 OS: Unix
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
34 + 32 = ?
Subscribe to this entry?

 [2002-11-03 05:36 UTC] tom at tomclegg dot net
I use php as a cgi usuing Apache's "Action" directive.  If I put a script in /u/joe/pub/example.php and visit http://joe/example.php/foo then Apache puts /example.php/foo in PATH_INFO, and PHP tries to open /u/joe/pub/example.php/foo.  (Internal server error; premature end of script headers)

This patch checks /u, /u/joe, /u/joe/pub, etc.; if one of them is a regular file (in this case /u/joe/pub/example.php) then that file is used as the script filename.  Now the script runs, with the entire PATH_INFO passed to it.  (It's up to the script to figure out which part to ignore.)

--- main/fopen_wrappers.c.orig	Fri Aug 23 01:00:49 2002
+++ main/fopen_wrappers.c	Sun Nov  3 02:54:26 2002
@@ -388,6 +388,23 @@
 		SG(request_info).path_translated = NULL;
 		return FAILURE;
+	/* check for /home/joe/public_html/example.php/pathinfo */
+	if (1) {
+		char *s;
+		for (s=filename+1; *s; s++) {
+			if (*s == PHP_DIR_SEPARATOR && *(s-1) != PHP_DIR_SEPARATOR) {
+				*s = 0;
+				if (0 == stat (filename, &st)) {
+					if (S_ISREG(st.st_mode)) {
+						break;
+					}
+				}
+			}
+		}
+	}
 	fp = VCWD_FOPEN(filename, "rb");
 	/* refuse to open anything that is not a regular file */


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 17:50 UTC]
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: *General Issues
 [2010-12-29 17:50 UTC]
Please try using this snapshot:
For Windows:

 [2010-12-29 17:51 UTC]
-Package: *General Issues +Package: CGI related
 [2013-02-18 00:04 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Feb 25 09:01:26 2024 UTC