Mercurial > hg > nginx
comparison src/http/v3/ngx_http_v3_table.c @ 9282:acb8548c00e9
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.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Tue, 28 May 2024 17:18:50 +0400 |
parents | 987bee4363d1 |
children |
comparison
equal
deleted
inserted
replaced
9281:081d4beeb591 | 9282:acb8548c00e9 |
---|---|
306 dt = &h3c->table; | 306 dt = &h3c->table; |
307 max = capacity / 32; | 307 max = capacity / 32; |
308 prev_max = dt->capacity / 32; | 308 prev_max = dt->capacity / 32; |
309 | 309 |
310 if (max > prev_max) { | 310 if (max > prev_max) { |
311 elts = ngx_alloc(max * sizeof(void *), c->log); | 311 elts = ngx_alloc((max + 1) * sizeof(void *), c->log); |
312 if (elts == NULL) { | 312 if (elts == NULL) { |
313 return NGX_ERROR; | 313 return NGX_ERROR; |
314 } | 314 } |
315 | 315 |
316 if (dt->elts) { | 316 if (dt->elts) { |