From: Stefan Fritsch Date: Mon, 9 Nov 2009 21:04:28 +0000 (+0000) Subject: Return 409 instead of 500 for a LOCK request if the parent resource does not X-Git-Tag: 2.3.3~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=710003318fb98eada09d7917ca835fb2b9bf4624;p=thirdparty%2Fapache%2Fhttpd.git Return 409 instead of 500 for a LOCK request if the parent resource does not exist or is not a collection. PR: 43465 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@834230 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 37bc2af8b56..73878422d25 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,9 @@ Changes with Apache 2.3.3 mod_proxy_ftp: NULL pointer dereference on error paths. [Stefan Fritsch , Joe Orton] + *) mod_dav_fs; Return 409 instead of 500 for a LOCK request if the parent + resource does not exist or is not a collection. PR 43465. [Stefan Fritsch] + *) mod_dav_fs: Return 409 instead of 500 for Litmus test case copy_nodestcoll (a COPY request where the parent of the destination resource does not exist). PR 39299. [Stefan Fritsch] diff --git a/modules/dav/main/mod_dav.c b/modules/dav/main/mod_dav.c index ab0f3d06528..bdc14448c01 100644 --- a/modules/dav/main/mod_dav.c +++ b/modules/dav/main/mod_dav.c @@ -2995,6 +2995,7 @@ static int dav_method_lock(request_rec *r) { dav_error *err; dav_resource *resource; + dav_resource *parent; const dav_hooks_locks *locks_hooks; int result; int depth; @@ -3026,6 +3027,20 @@ static int dav_method_lock(request_rec *r) if (err != NULL) return dav_handle_err(r, err, NULL); + /* Check if parent collection exists */ + if ((err = resource->hooks->get_parent_resource(resource, &parent)) != NULL) { + /* ### add a higher-level description? */ + return dav_handle_err(r, err, NULL); + } + if (parent && (!parent->exists || parent->collection != 1)) { + err = dav_new_error(r->pool, HTTP_CONFLICT, 0, + apr_psprintf(r->pool, + "The parent resource of %s does not " + "exist or is not a collection.", + ap_escape_html(r->pool, r->uri))); + return dav_handle_err(r, err, NULL); + } + /* * Open writable. Unless an error occurs, we'll be * writing into the database.