summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2019-02-07 17:40:27 +0300
committerValentin Bartenev <vbart@nginx.com>2019-02-07 17:40:27 +0300
commit83dd67d2164bc3df61e8ede97467c0bbc31e395b (patch)
tree661c8af478e1738557689967ff6d1c9def21d335
parent52c1895cd21c50a1a74b925c8dca1d0075d79970 (diff)
downloadunit-83dd67d2164bc3df61e8ede97467c0bbc31e395b.tar.gz
unit-83dd67d2164bc3df61e8ede97467c0bbc31e395b.tar.bz2
Rejecting requests with invalid "Content-Length".
-rw-r--r--src/nxt_http_request.c12
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;
}