aboutsummaryrefslogtreecommitdiff
path: root/src/http/v3/ngx_http_v3_request.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2021-02-17 11:58:32 +0300
committerRoman Arutyunyan <arut@nginx.com>2021-02-17 11:58:32 +0300
commite0425791d484b8e1e77cf39f6ca4da33b5c6e3a3 (patch)
tree7a9e84ca0eaf163fcecdefb471f47c256e8de7e2 /src/http/v3/ngx_http_v3_request.c
parentffb099bf52e70c0cbdb1ed5555645f12ec6b2322 (diff)
downloadnginx-e0425791d484b8e1e77cf39f6ca4da33b5c6e3a3.tar.gz
nginx-e0425791d484b8e1e77cf39f6ca4da33b5c6e3a3.zip
HTTP/3: limited client header size.
The limit is the size of all large client header buffers. Client header size is the total size of all client header names and values.
Diffstat (limited to 'src/http/v3/ngx_http_v3_request.c')
-rw-r--r--src/http/v3/ngx_http_v3_request.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c
index ef3053689..689d9fc61 100644
--- a/src/http/v3/ngx_http_v3_request.c
+++ b/src/http/v3/ngx_http_v3_request.c
@@ -118,6 +118,9 @@ ngx_http_v3_init(ngx_connection_t *c)
return;
}
+ r->v3_parse->header_limit = cscf->large_client_header_buffers.size
+ * cscf->large_client_header_buffers.num;
+
c->data = r;
rev = c->read;
@@ -261,11 +264,23 @@ static ngx_int_t
ngx_http_v3_process_header(ngx_http_request_t *r, ngx_str_t *name,
ngx_str_t *value)
{
+ size_t len;
ngx_table_elt_t *h;
ngx_http_header_t *hh;
ngx_http_core_srv_conf_t *cscf;
ngx_http_core_main_conf_t *cmcf;
+ len = name->len + value->len;
+
+ if (len > r->v3_parse->header_limit) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent too large header");
+ ngx_http_finalize_request(r, NGX_HTTP_REQUEST_HEADER_TOO_LARGE);
+ return NGX_ERROR;
+ }
+
+ r->v3_parse->header_limit -= len;
+
if (ngx_http_v3_validate_header(r, name, value) != NGX_OK) {
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
return NGX_ERROR;