[nginx] HTTP/3: fixed dynamic table overflow.

Sergey Kandaurov pluknet at nginx.com
Wed May 29 14:57:48 UTC 2024


details:   https://hg.nginx.org/nginx/rev/a0cbbdeebccd
branches:  
changeset: 9252:a0cbbdeebccd
user:      Roman Arutyunyan <arut at nginx.com>
date:      Tue May 28 17:18:50 2024 +0400
description:
HTTP/3: fixed dynamic table overflow.

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.

diffstat:

 src/http/v3/ngx_http_v3_table.c |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 387470a87c8a -r a0cbbdeebccd src/http/v3/ngx_http_v3_table.c
--- a/src/http/v3/ngx_http_v3_table.c	Tue May 28 17:18:28 2024 +0400
+++ b/src/http/v3/ngx_http_v3_table.c	Tue May 28 17:18:50 2024 +0400
@@ -308,7 +308,7 @@ ngx_http_v3_set_capacity(ngx_connection_
     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;
         }


More information about the nginx-devel mailing list