Skip to content

Commit 3926598

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
1 parent 5c7eac0 commit 3926598

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
@@ -1521,8 +1521,16 @@ static dav_error * dav_fs_remove_resource(dav_resource *resource,
15211521

15221522
/* not a collection; remove the file and its properties */
15231523
if ((status = apr_file_remove(info->pathname, info->pool)) != APR_SUCCESS) {
1524-
/* ### put a description in here */
1525-
return dav_new_error(info->pool, HTTP_FORBIDDEN, 0, status, NULL);
1524+
if (APR_STATUS_IS_ENOENT(status)) {
1525+
/* Return a 404 if there is a race with another DELETE,
1526+
* per RFC 4918§9.6. */
1527+
return dav_new_error(info->pool, HTTP_NOT_FOUND, 0, status,
1528+
"Cannot remove already-removed resource.");
1529+
}
1530+
else {
1531+
return dav_new_error(info->pool, HTTP_FORBIDDEN, 0, status,
1532+
"Cannot remove resource");
1533+
}
15261534
}
15271535

15281536
/* update resource state */

0 commit comments

Comments
 (0)