|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 02:00:01 2025 UTC |
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 */