summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2020-02-05 16:29:23 +0300
committerSergey Kandaurov <pluknet@nginx.com>2020-02-05 16:29:23 +0300
commit16168dcb01ed5dbf6365be0d9ea0da68bf479194 (patch)
tree0459f140cacdd77d4892eec56b71997a1eca2ad4
parentb7ea950a12de0619c8030e4887f6901b3364d208 (diff)
HTTP/2: fixed socket leak with an incomplete HEADERS frame.
A connection could get stuck without timers if a client has partially sent the HEADERS frame such that it was split on the individual header boundary. In this case, it cannot be processed without the rest of the HEADERS frame. The fix is to call ngx_http_v2_state_headers_save() in this case. Normally, it would be called from the ngx_http_v2_state_header_block() handler on the next iteration, when there is not enough data to continue processing. This isn't the case if recv_buffer became empty and there's no more data to read.
-rw-r--r--src/http/v2/ngx_http_v2.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
index 2974e9c79..8b0fc53b0 100644
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -1719,8 +1719,13 @@ ngx_http_v2_state_header_complete(ngx_http_v2_connection_t *h2c, u_char *pos,
ngx_http_v2_stream_t *stream;
if (h2c->state.length) {
- h2c->state.handler = ngx_http_v2_state_header_block;
- return pos;
+ if (end - pos > 0) {
+ h2c->state.handler = ngx_http_v2_state_header_block;
+ return pos;
+ }
+
+ return ngx_http_v2_state_headers_save(h2c, pos, end,
+ ngx_http_v2_state_header_block);
}
if (!(h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG)) {