From: Stefan Fritsch Date: Mon, 3 Oct 2011 20:37:49 +0000 (+0000) Subject: Enforce LimitRequestFieldSize after multiple headers with the same X-Git-Tag: 2.3.15~179 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4092c7a7d532c41f8c9bf084f58bf5af8894550;p=apache Enforce LimitRequestFieldSize after multiple headers with the same name have been merged. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1178566 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 3f8e0936a4..c63fa39bb3 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,9 @@ Changes with Apache 2.3.15 PR 51714. [Stefan Fritsch, Jim Jagielski, Ruediger Pluem, Eric Covener, ] + *) core: Enforce LimitRequestFieldSize after multiple headers with the same + name have been merged. [Stefan Fritsch] + *) mod_ssl: If MaxMemFree is set, ask OpenSSL >= 1.0.0 to reduce memory usage. PR 51618. [Cristian Rodríguez , Stefan Fritsch] diff --git a/server/protocol.c b/server/protocol.c index f29c915bab..896a8fd603 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -685,6 +685,23 @@ static int read_request_line(request_rec *r, apr_bucket_brigade *bb) return 1; } +static int table_do_fn_check_lengths(void *r_, const char *key, + const char *value) +{ + request_rec *r = r_; + if (value == NULL || r->server->limit_req_fieldsize >= strlen(value) ) + return 1; + + r->status = HTTP_BAD_REQUEST; + apr_table_setn(r->notes, "error-notes", + apr_pstrcat(r->pool, "Size of a request header field " + "after merging exceeds server limit.
" + "\n
\n",
+                               ap_escape_html(r->pool, key),
+                               "
\n", NULL)); + return 0; +} + AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb) { char *last_field = NULL; @@ -850,6 +867,9 @@ AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb * field-name, following RFC 2616, 4.2. */ apr_table_compress(r->headers_in, APR_OVERLAP_TABLES_MERGE); + + /* enforce LimitRequestFieldSize for merged headers */ + apr_table_do(table_do_fn_check_lengths, r, r->headers_in, NULL); } AP_DECLARE(void) ap_get_mime_headers(request_rec *r)