]> git.feebdaed.xyz Git - 0xmirror/nginx.git/commitdiff
HTTP/3: fixed dynamic table overflow.
authorRoman Arutyunyan <arut@nginx.com>
Tue, 28 May 2024 13:18:50 +0000 (17:18 +0400)
committerRoman Arutyunyan <arut@nginx.com>
Tue, 28 May 2024 13:18:50 +0000 (17:18 +0400)
While inserting a new entry into the dynamic table, first the entry is added,
and then older entries are evicted until table size is within capacity.  After
the first step, the number of entries may temporarily exceed the maximum
calculated from capacity by one entry, which previously caused table overflow.

The easiest way to trigger the issue is to keep adding entries with empty names
and values until first eviction.

The issue was introduced by 987bee4363d1.

src/http/v3/ngx_http_v3_table.c

index f49a8fc5e2f50b4b98738136904cb5ca45997a6b..428e7326b91918de6f275461cefade7da5855652 100644 (file)
@@ -308,7 +308,7 @@ ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity)
     prev_max = dt->capacity / 32;
 
     if (max > prev_max) {
-        elts = ngx_alloc(max * sizeof(void *), c->log);
+        elts = ngx_alloc((max + 1) * sizeof(void *), c->log);
         if (elts == NULL) {
             return NGX_ERROR;
         }