]> granicus.if.org Git - apache/commitdiff
Cause dav_fs_get_parent_resource to fail if the file path is entirely
authorWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 24 Jan 2002 15:23:58 +0000 (15:23 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Thu, 24 Jan 2002 15:23:58 +0000 (15:23 +0000)
  invalid or incomplete, or if it is root [determined by the platform's
  apr implemention].  Identified by Greg Stein.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92998 13f79535-47bb-0310-9956-ffa450edef68

modules/dav/fs/repos.c

index 2ebdc0bbf45f35e9d8dc47834019a2ea76ccd3ff..3e2f4711e409b976eaaa0669a339a913275a8c85 100644 (file)
@@ -735,10 +735,18 @@ static dav_error * dav_fs_get_parent_resource(const dav_resource *resource,
     dav_resource *parent_resource;
     apr_status_t rv;
     char *dirpath;
+    char *testroot;
+    char *testpath;
 
-    /* If given resource is root, then there is no parent */
-    if (strcmp(resource->uri, "/") == 0 ||
-        ap_os_is_path_absolute(ctx->pool, ctx->pathname)) {
+    /* If given resource is root, then there is no parent.
+     * Unless we can retrieve the filepath root, this is
+     * intendend to fail.  If we split the root and
+     * no path info remains, then we also fail.
+     */
+    testpath = ctx->pathname;
+    rv = apr_filepath_root(&testroot, &testpath, ctx->pool);
+    if ((rv != APR_SUCCESS && rv != APR_ERELATIVE) 
+        || !testpath || !*testpath) {
         *result_parent = NULL;
         return NULL;
     }