changeset 8403:c101438c69a4 quic

HTTP/3: prevent array access by negative index for unknown streams. Currently there are no such streams, but the function ngx_http_v3_get_uni_stream() supports them.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 19 May 2020 15:41:41 +0300
parents af22b60a905b
children e5d4f057a6cb
files src/http/v3/ngx_http_v3_streams.c
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/v3/ngx_http_v3_streams.c
+++ b/src/http/v3/ngx_http_v3_streams.c
@@ -320,7 +320,9 @@ ngx_http_v3_get_uni_stream(ngx_connectio
     sc->read->handler = ngx_http_v3_uni_read_handler;
     sc->write->handler = ngx_http_v3_dummy_write_handler;
 
-    h3c->known_streams[index] = sc;
+    if (index >= 0) {
+        h3c->known_streams[index] = sc;
+    }
 
     n = (u_char *) ngx_http_v3_encode_varlen_int(buf, type) - buf;