Checking Content-Length value right after header parse.
The check was moved from the request body read stage.
This commit is contained in:
@@ -847,11 +847,6 @@ nxt_h1p_request_body_read(nxt_task_t *task, nxt_http_request_t *r)
|
|||||||
goto ready;
|
goto ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r->content_length_n > (nxt_off_t) r->conf->socket_conf->max_body_size) {
|
|
||||||
status = NXT_HTTP_PAYLOAD_TOO_LARGE;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
body_length = (size_t) r->content_length_n;
|
body_length = (size_t) r->content_length_n;
|
||||||
|
|
||||||
b = r->body;
|
b = r->body;
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ nxt_int_t
|
|||||||
nxt_http_request_content_length(void *ctx, nxt_http_field_t *field,
|
nxt_http_request_content_length(void *ctx, nxt_http_field_t *field,
|
||||||
uintptr_t data)
|
uintptr_t data)
|
||||||
{
|
{
|
||||||
nxt_off_t n;
|
nxt_off_t n, max_body_size;
|
||||||
nxt_http_request_t *r;
|
nxt_http_request_t *r;
|
||||||
|
|
||||||
r = ctx;
|
r = ctx;
|
||||||
@@ -198,6 +198,13 @@ nxt_http_request_content_length(void *ctx, nxt_http_field_t *field,
|
|||||||
|
|
||||||
if (nxt_fast_path(n >= 0)) {
|
if (nxt_fast_path(n >= 0)) {
|
||||||
r->content_length_n = n;
|
r->content_length_n = n;
|
||||||
|
|
||||||
|
max_body_size = r->conf->socket_conf->max_body_size;
|
||||||
|
|
||||||
|
if (nxt_slow_path(n > max_body_size)) {
|
||||||
|
return NXT_HTTP_PAYLOAD_TOO_LARGE;
|
||||||
|
}
|
||||||
|
|
||||||
return NXT_OK;
|
return NXT_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user