comparison src/http/v2/ngx_http_v2.c @ 9275:199dc0d6b05b

Added max_headers directive. The directive limits the number of request headers accepted from clients. While the total amount of headers is believed to be sufficiently limited by the existing buffer size limits (client_header_buffer_size and large_client_header_buffers), the additional limit on the number of headers might be beneficial to better protect backend servers. Requested by Maksim Yevmenkin.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 24 May 2024 00:20:01 +0300
parents 388a801e9bb9
children 4a0cd107c0f1
comparison
equal deleted inserted replaced
9274:46ecad404a29 9275:199dc0d6b05b
1812 return ngx_http_v2_connection_error(h2c, 1812 return ngx_http_v2_connection_error(h2c,
1813 NGX_HTTP_V2_INTERNAL_ERROR); 1813 NGX_HTTP_V2_INTERNAL_ERROR);
1814 } 1814 }
1815 1815
1816 } else { 1816 } else {
1817 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
1818
1819 if (r->headers_in.count++ >= cscf->max_headers) {
1820 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
1821 "client sent too many header lines");
1822 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_HEADER_TOO_LARGE);
1823 goto error;
1824 }
1825
1817 h = ngx_list_push(&r->headers_in.headers); 1826 h = ngx_list_push(&r->headers_in.headers);
1818 if (h == NULL) { 1827 if (h == NULL) {
1819 return ngx_http_v2_connection_error(h2c, 1828 return ngx_http_v2_connection_error(h2c,
1820 NGX_HTTP_V2_INTERNAL_ERROR); 1829 NGX_HTTP_V2_INTERNAL_ERROR);
1821 } 1830 }