php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59452 Wrong DocRoot- Assumptions
Submitted: 2010-10-08 11:20 UTC Modified: 2010-11-21 08:23 UTC
From: andy at boeckler dot org Assigned: martynas (profile)
Status: Closed Package: htscanner (PECL)
PHP Version: 5.3.2 OS: Mac OS X 10.6
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andy at boeckler dot org
New email:
PHP Version: OS:

 

 [2010-10-08 11:20 UTC] andy at boeckler dot org
Description:
------------
When strlen(doc_root) > strlen(cwd) htscanner doesn't start 
to scan .htaccess in cwd.

This is possible with apache-mod userdir.

Reproduce code:
---------------
DocumentRoot /opt/local/apache2/htdocs

UserDir Sites
.htaccess is in
/Users/joe/Sites/ 


=>
/opt/local/apache2/htdocs ->  25
/Users/joe/Sites/ -> 17

This code won't even start:
for (i = doc_root_len - 1; i < cwd_len; i++) {
   if (cwd[i] == PHP_DIR_SEPARATOR) {


Expected result:
----------------
parsing of /User/joe/Sites/.htaccess

Actual result:
--------------
nothing is parsed

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-13 18:07 UTC] martynas at venck dot us
Indeed, the code assumes CWD is a subset of DocumentRoot, 
which is obviously wrong in your (UserDir) case.

Could you please try the patch below?

- Check whether CWD is a subset of DocumentRoot.  Otherwise, 
walk thru the whole CWD.  Fixes htscanner with UserDir.  
(#19019)

Index: htscanner.c
============================================================
=======
--- htscanner.c	(revision 303747)
+++ htscanner.c	(working copy)
@@ -450,11 +450,16 @@
 #endif
 
 	if (cwd != NULL && doc_root != NULL) {
-		size_t i, ht_len, tmp;
+		size_t i = 0, ht_len, tmp;
 
 		ht_len = strlen(HTG(config_file));
-	
-		for (i = doc_root_len - 1; i < cwd_len; i++) 
{
+
+		/* Check whether cwd is a subset of 
doc_root. */
+		if (strncmp(doc_root, cwd, doc_root_len) == 
0) {
+			i = doc_root_len - 1;
+		}
+
+		for (; i < cwd_len; i++) {
 			if (cwd[i] == PHP_DIR_SEPARATOR) {
 				char file[MAXPATHLEN + 1];
 				tmp = i + 1 + ht_len; /* + 1 
for trailing slash */
 [2010-11-21 08:23 UTC] martynas at venck dot us
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 04 02:01:27 2024 UTC