]> git.kaiwu.me - nginx.git/commitdiff
HTTP/3: null-terminate empty header value.
authorRoman Arutyunyan <arut@nginx.com>
Tue, 17 Nov 2020 20:54:10 +0000 (20:54 +0000)
committerRoman Arutyunyan <arut@nginx.com>
Tue, 17 Nov 2020 20:54:10 +0000 (20:54 +0000)
Header value returned from the HTTP parser is expected to be null-terminated or
have a spare byte after the value bytes.  When an empty header value was passed
by client in a literal header representation, neither was true.  This could
result in segfault.  The fix is to assign a literal empty null-terminated
string in this case.

Thanks to Andrey Kolyshkin.

src/http/v3/ngx_http_v3_parse.c

index d5ff3cb8f2b969095ea8257a9003da0fc982782d..afe4424640256bd9c9e521e1fe72f46fabfec029 100644 (file)
@@ -746,6 +746,7 @@ ngx_http_v3_parse_header_l(ngx_connection_t *c,
 
         st->literal.length = st->pint.value;
         if (st->literal.length == 0) {
+            st->value.data = (u_char *) "";
             goto done;
         }