From c7b3faf36848b4c1f25fc6df12851b1aa2e3a492 Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Thu, 24 Jan 2002 15:23:58 +0000 Subject: [PATCH] Cause dav_fs_get_parent_resource to fail if the file path is entirely 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/dav/fs/repos.c b/modules/dav/fs/repos.c index 2ebdc0bbf4..3e2f4711e4 100644 --- a/modules/dav/fs/repos.c +++ b/modules/dav/fs/repos.c @@ -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; } -- 2.40.0