]> git.kaiwu.me - nginx.git/commitdiff
HTTP/3: fixed potential type overflow in string literal parser.
authorSergey Kandaurov <pluknet@nginx.com>
Thu, 5 Sep 2024 15:35:43 +0000 (19:35 +0400)
committerpluknet <pluknet@nginx.com>
Wed, 23 Jul 2025 13:24:43 +0000 (17:24 +0400)
This might happen for Huffman encoded string literals as the result
of length expansion.  Notably, the maximum length of string literals
is already limited with the "large_client_header_buffers" directive,
so this was only possible with nonsensically large configured limits.

src/http/v3/ngx_http_v3_parse.c

index 436765c8a4026aee8804beca1afe790dd9a38c74..bcbf0dbe1208d8ee92d001b8a22ab005ad32440e 100644 (file)
@@ -623,6 +623,12 @@ ngx_http_v3_parse_literal(ngx_connection_t *c, ngx_http_v3_parse_literal_t *st,
             }
 
             if (st->huffman) {
+                if (n > NGX_MAX_INT_T_VALUE / 8) {
+                    ngx_log_error(NGX_LOG_INFO, c->log, 0,
+                                  "client sent too large field line");
+                    return NGX_HTTP_V3_ERR_EXCESSIVE_LOAD;
+                }
+
                 n = n * 8 / 5;
                 st->huffstate = 0;
             }