diff options
author | Valentin Bartenev <vbart@nginx.com> | 2019-02-07 17:40:27 +0300 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2019-02-07 17:40:27 +0300 |
commit | a2cbe890a19ca2341de5b54ffe9c9f5924cf10ec (patch) | |
tree | ea898134c23756e0b4ccfc5ce9710dca3c869806 /src/nxt_http_request.c | |
parent | d60fbc6d4476982fb683d485859acd2c29a6837c (diff) | |
download | unit-a2cbe890a19ca2341de5b54ffe9c9f5924cf10ec.tar.gz unit-a2cbe890a19ca2341de5b54ffe9c9f5924cf10ec.tar.bz2 |
Rejecting requests with invalid "Content-Length".
Diffstat (limited to '')
-rw-r--r-- | src/nxt_http_request.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/nxt_http_request.c b/src/nxt_http_request.c index b80998cb..c8adb499 100644 --- a/src/nxt_http_request.c +++ b/src/nxt_http_request.c @@ -79,14 +79,20 @@ nxt_int_t nxt_http_request_content_length(void *ctx, nxt_http_field_t *field, uintptr_t data) { + nxt_off_t n; nxt_http_request_t *r; r = ctx; - r->content_length = field; - r->content_length_n = nxt_off_t_parse(field->value, field->value_length); - return NXT_OK; + n = nxt_off_t_parse(field->value, field->value_length); + + if (nxt_fast_path(n >= 0)) { + r->content_length_n = n; + return NXT_OK; + } + + return NXT_ERROR; } |