summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2006-03-01 17:41:22 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2006-03-01 17:41:22 +0000
commit2f7294066948b0365b730832644fda1a44f2a8e3 (patch)
tree661155af1614e455b731a56dd7138f40a028dca3
parent3d7e6f7de860b177d4d51b476a5ab97f635e5d12 (diff)
downloadlibapr-2f7294066948b0365b730832644fda1a44f2a8e3.tar.gz
Revert 239927 and simplify a much more basic optimization
to address if a basepath existed to compare the results to. Also reverts my attempt 382043 to fix the flaw. Any further 'features' to support alternate constructs of NOTABOVEROOT tested base and add paths must be brought up on list for discussion. PR: 38801 Reported by: <kevin_wise motorola.com> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@382095 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--file_io/win32/filepath.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/file_io/win32/filepath.c b/file_io/win32/filepath.c
index 8b7b32445..1912a1c80 100644
--- a/file_io/win32/filepath.c
+++ b/file_io/win32/filepath.c
@@ -800,18 +800,17 @@ APR_DECLARE(apr_status_t) apr_filepath_merge(char **newpath,
* is still within given basepath. Note that the root path
* segment is thoroughly tested prior to path parsing.
*/
- if ((flags & APR_FILEPATH_NOTABOVEROOT) && (baselen || rootlen)) {
- if (basepath[baselen - 1] != '/' && basepath[baselen - 1] != '\\') {
- if (baselen && memcmp(basepath, path + rootlen, baselen))
- return APR_EABOVEROOT;
-
- /* Ahem... if we weren't given a trailing slash on the basepath,
- * we better be sure that /foo wasn't replaced with /foobar!
- */
- if (path[rootlen + baselen] && path[rootlen + baselen] != '/'
- && path[rootlen + baselen] != '\\')
- return APR_EABOVEROOT;
- }
+ if ((flags & APR_FILEPATH_NOTABOVEROOT) && baselen) {
+ if (memcmp(basepath, path + rootlen, baselen) != 0)
+ return APR_EABOVEROOT;
+
+ /* Ahem... if we have a basepath without a trailing slash,
+ * we better be sure that /foo wasn't replaced with /foobar!
+ */
+ if (basepath[baselen - 1] != '/' && basepath[baselen - 1] != '\\'
+ && path[rootlen + baselen] && path[rootlen + baselen] != '/'
+ && path[rootlen + baselen] != '\\')
+ return APR_EABOVEROOT;
}
if (addpath && (flags & APR_FILEPATH_TRUENAME)) {