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
 [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: Mon Dec 30 14:01:28 2024 UTC