]> granicus.if.org Git - apache/commitdiff
Return 409 instead of 500 for a LOCK request if the parent resource does not
authorStefan Fritsch <sf@apache.org>
Mon, 9 Nov 2009 21:04:28 +0000 (21:04 +0000)
committerStefan Fritsch <sf@apache.org>
Mon, 9 Nov 2009 21:04:28 +0000 (21:04 +0000)
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

CHANGES
modules/dav/main/mod_dav.c

diff --git a/CHANGES b/CHANGES
index 37bc2af8b567ad32e88d9782a1b92da4180d81fe..73878422d25e8791967cb88810a09ad0b7599a65 100644 (file)
--- 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 <sf fritsch.de>, 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]
index ab0f3d0652853d7dd0ffb1cbddf331fca5e6e9fc..bdc14448c013e3a71e4ec237fd96f2baa814d034 100644 (file)
@@ -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.