diff options
-rw-r--r-- | src/nxt_http_parse.c | 18 | ||||
-rw-r--r-- | src/test/nxt_http_parse_test.c | 6 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/nxt_http_parse.c b/src/nxt_http_parse.c index 65de0d60..f8249abb 100644 --- a/src/nxt_http_parse.c +++ b/src/nxt_http_parse.c @@ -606,7 +606,7 @@ static nxt_int_t nxt_http_parse_field_value(nxt_http_request_parse_t *rp, u_char **pos, u_char *end) { - u_char *p, ch; + u_char *p, *start, ch; size_t len; p = *pos; @@ -625,14 +625,16 @@ nxt_http_parse_field_value(nxt_http_request_parse_t *rp, u_char **pos, p++; } - *pos = p; + start = p; p += rp->field_value.length; p = nxt_http_lookup_field_end(p, end); if (nxt_slow_path(p == end)) { - len = p - *pos; + *pos = start; + + len = p - start; if (nxt_slow_path(len > NXT_HTTP_MAX_FIELD_VALUE)) { return NXT_HTTP_PARSE_TOO_LARGE_FIELD; @@ -649,22 +651,22 @@ nxt_http_parse_field_value(nxt_http_request_parse_t *rp, u_char **pos, return NXT_HTTP_PARSE_INVALID; } - if (nxt_fast_path(p != *pos)) { + *pos = p; + + if (nxt_fast_path(p != start)) { while (p[-1] == ' ') { p--; } } - len = p - *pos; + len = p - start; if (nxt_slow_path(len > NXT_HTTP_MAX_FIELD_VALUE)) { return NXT_HTTP_PARSE_TOO_LARGE_FIELD; } rp->field_value.length = len; - rp->field_value.start = *pos; - - *pos = p; + rp->field_value.start = start; return nxt_http_parse_field_end(rp, pos, end); } diff --git a/src/test/nxt_http_parse_test.c b/src/test/nxt_http_parse_test.c index adf35168..d00fc1af 100644 --- a/src/test/nxt_http_parse_test.c +++ b/src/test/nxt_http_parse_test.c @@ -228,6 +228,12 @@ static nxt_http_parse_test_case_t nxt_http_test_cases[] = { }, { nxt_string("GET / HTTP/1.1\r\n" + "Host:example.com \r\n\r\n"), + NXT_DONE, + NULL, { NULL } + }, + { + nxt_string("GET / HTTP/1.1\r\n" "Host:\r\n\r\n"), NXT_DONE, NULL, { NULL } |