Skip to content

Commit 89af71a

Browse files
committed
* modules/dav/fs/repos.c (dav_fs_remove_resource):
Return a 404 if apr_file_remove() fails with an ENOENT error, likely due to a race with another DELETE. PR: 60746 Github: closes #535 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1926172 13f79535-47bb-0310-9956-ffa450edef68 (cherry picked from commit 3926598)
1 parent 3c81898 commit 89af71a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

changes-entries/pr60746.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*) mod_dav_fs: Return a 404 for DELETE if deletion fails because the
2+
resource no longer exists. PR 60746. [Joe Orton]

modules/dav/fs/repos.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,8 +1486,16 @@ static dav_error * dav_fs_remove_resource(dav_resource *resource,
14861486

14871487
/* not a collection; remove the file and its properties */
14881488
if ((status = apr_file_remove(info->pathname, info->pool)) != APR_SUCCESS) {
1489-
/* ### put a description in here */
1490-
return dav_new_error(info->pool, HTTP_FORBIDDEN, 0, status, NULL);
1489+
if (APR_STATUS_IS_ENOENT(status)) {
1490+
/* Return a 404 if there is a race with another DELETE,
1491+
* per RFC 4918§9.6. */
1492+
return dav_new_error(info->pool, HTTP_NOT_FOUND, 0, status,
1493+
"Cannot remove already-removed resource.");
1494+
}
1495+
else {
1496+
return dav_new_error(info->pool, HTTP_FORBIDDEN, 0, status,
1497+
"Cannot remove resource");
1498+
}
14911499
}
14921500

14931501
/* update resource state */

0 commit comments

Comments
 (0)