php.net |  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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;
+					}
+				}
+				*s = PHP_DIR_SEPARATOR;
+			}
+		}
+	}
+
 	fp = VCWD_FOPEN(filename, "rb");
 
 	/* refuse to open anything that is not a regular file */

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2010-12-29 17:51 UTC] jani@php.net
-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-2021 The PHP Group
All rights reserved.
Last updated: Mon Dec 06 08:03:34 2021 UTC