aboutsummaryrefslogtreecommitdiff
path: root/src/http/v3/ngx_http_v3_table.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2024-05-28 17:18:50 +0400
committerRoman Arutyunyan <arut@nginx.com>2024-05-28 17:18:50 +0400
commitcca5655dd9ba349817946a0db14f8b1f633f700a (patch)
tree9ef3f2a787203ebf83a00302da3ae2944a8e79f6 /src/http/v3/ngx_http_v3_table.c
parent0fd59c8b565c4577f7c25b9e6450bd311d18f5e2 (diff)
downloadnginx-cca5655dd9ba349817946a0db14f8b1f633f700a.tar.gz
nginx-cca5655dd9ba349817946a0db14f8b1f633f700a.zip
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 (limited to 'src/http/v3/ngx_http_v3_table.c')
-rw-r--r--src/http/v3/ngx_http_v3_table.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/http/v3/ngx_http_v3_table.c b/src/http/v3/ngx_http_v3_table.c
index f49a8fc5e..428e7326b 100644
--- a/src/http/v3/ngx_http_v3_table.c
+++ b/src/http/v3/ngx_http_v3_table.c
@@ -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;
}