Skip to content

Commit e653b97

Browse files
author
manu
committed
Use ap_parse_strict_length() to parse client-supplied Content-Length
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1908144 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1f89cbb commit e653b97

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

modules/dav/fs/quota.c

+14-6
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,20 @@ int dav_fs_quota_precondition(request_rec *r,
320320
/*
321321
* If PUT has Content-Length, we can forecast overquota
322322
*/
323-
if ((lenhdr = apr_table_get(r->headers_in, "Content-Length")) &&
324-
(atol(lenhdr) > available_bytes)) {
325-
status = HTTP_INSUFFICIENT_STORAGE;
326-
*err = dav_new_error_tag(r->pool, status, 0, 0,
327-
msg, NULL, tag);
328-
goto out;
323+
if (lenhdr = apr_table_get(r->headers_in, "Content-Length")) {
324+
if (!ap_parse_strict_length(&size, lenhdr)) {
325+
status = HTTP_BAD_REQUEST;
326+
*err = dav_new_error(r->pool, status, 0, 0,
327+
"client sent invalid Content-Length");
328+
goto out;
329+
}
330+
331+
if (size > available_bytes) {
332+
status = HTTP_INSUFFICIENT_STORAGE;
333+
*err = dav_new_error_tag(r->pool, status, 0, 0,
334+
msg, NULL, tag);
335+
goto out;
336+
}
329337
}
330338
break;
331339
case M_COPY: /* FALLTHROUGH */

0 commit comments

Comments
 (0)