mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
HTTP/2: changed behavior of the "http2_max_field_size" directive.
Now it limits only the maximum length of literal string (either raw or compressed) in HPACK request header fields. It's easier to understand and to describe in the documentation.
This commit is contained in:
parent
edf30961e6
commit
090c471032
@ -1207,7 +1207,6 @@ ngx_http_v2_state_header_block(ngx_http_v2_connection_t *h2c, u_char *pos,
|
||||
u_char ch;
|
||||
ngx_int_t value;
|
||||
ngx_uint_t indexed, size_update, prefix;
|
||||
ngx_http_v2_srv_conf_t *h2scf;
|
||||
|
||||
if (end - pos < 1) {
|
||||
return ngx_http_v2_state_save(h2c, pos, end,
|
||||
@ -1288,22 +1287,13 @@ ngx_http_v2_state_header_block(ngx_http_v2_connection_t *h2c, u_char *pos,
|
||||
return ngx_http_v2_state_header_complete(h2c, pos, end);
|
||||
}
|
||||
|
||||
h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
|
||||
ngx_http_v2_module);
|
||||
|
||||
h2c->state.field_limit = h2scf->max_field_size;
|
||||
|
||||
if (value == 0) {
|
||||
h2c->state.parse_name = 1;
|
||||
|
||||
} else {
|
||||
if (ngx_http_v2_get_indexed_header(h2c, value, 1) != NGX_OK) {
|
||||
} else if (ngx_http_v2_get_indexed_header(h2c, value, 1) != NGX_OK) {
|
||||
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_COMP_ERROR);
|
||||
}
|
||||
|
||||
h2c->state.field_limit -= h2c->state.header.name.len;
|
||||
}
|
||||
|
||||
h2c->state.parse_value = 1;
|
||||
|
||||
return ngx_http_v2_state_field_len(h2c, pos, end);
|
||||
@ -1317,6 +1307,7 @@ ngx_http_v2_state_field_len(ngx_http_v2_connection_t *h2c, u_char *pos,
|
||||
size_t alloc;
|
||||
ngx_int_t len;
|
||||
ngx_uint_t huff;
|
||||
ngx_http_v2_srv_conf_t *h2scf;
|
||||
|
||||
if (!(h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG)
|
||||
&& h2c->state.length < NGX_HTTP_V2_INT_OCTETS)
|
||||
@ -1363,14 +1354,16 @@ ngx_http_v2_state_field_len(ngx_http_v2_connection_t *h2c, u_char *pos,
|
||||
"http2 hpack %s string length: %i",
|
||||
huff ? "encoded" : "raw", len);
|
||||
|
||||
if ((size_t) len > h2c->state.field_limit) {
|
||||
h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
|
||||
ngx_http_v2_module);
|
||||
|
||||
if ((size_t) len > h2scf->max_field_size) {
|
||||
ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
|
||||
"client exceeded http2_max_field_size limit");
|
||||
|
||||
return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM);
|
||||
}
|
||||
|
||||
h2c->state.field_limit -= len;
|
||||
h2c->state.field_rest = len;
|
||||
|
||||
if (h2c->state.stream == NULL && !h2c->state.index) {
|
||||
|
@ -80,7 +80,6 @@ typedef struct {
|
||||
unsigned index:1;
|
||||
ngx_http_v2_header_t header;
|
||||
size_t header_limit;
|
||||
size_t field_limit;
|
||||
u_char field_state;
|
||||
u_char *field_start;
|
||||
u_char *field_end;
|
||||
|
Loading…
Reference in New Issue
Block a user