# HG changeset patch # User Roman Arutyunyan # Date 1589461352 -10800 # Node ID 26cb2f3259b1d49b00e61df50945cfacdca8a4aa # Parent 5b367070cc9c4d0b1a0d82ec130c88a4881b7314 HTTP/3: reallocate strings inserted into the dynamic table. They should always be allocated from the main QUIC connection pool. diff --git a/src/http/v3/ngx_http_v3_tables.c b/src/http/v3/ngx_http_v3_tables.c --- a/src/http/v3/ngx_http_v3_tables.c +++ b/src/http/v3/ngx_http_v3_tables.c @@ -149,12 +149,15 @@ ngx_http_v3_ref_insert(ngx_connection_t ngx_uint_t index, ngx_str_t *value) { ngx_array_t *dt; + ngx_connection_t *pc; ngx_http_v3_header_t *ref, *h; ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 ref insert %s[$ui] \"%V\"", dynamic ? "dynamic" : "static", index, value); + pc = c->qs->parent; + ref = ngx_http_v3_lookup_table(c, dynamic, index); if (ref == NULL) { return NGX_ERROR; @@ -171,7 +174,14 @@ ngx_http_v3_ref_insert(ngx_connection_t } h->name = ref->name; - h->value = *value; + + h->value.data = ngx_pstrdup(pc->pool, value); + if (h->value.data == NULL) { + h->value.len = 0; + return NGX_ERROR; + } + + h->value.len = value->len; if (ngx_http_v3_new_header(c) != NGX_OK) { return NGX_ERROR; @@ -186,11 +196,14 @@ ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *value) { ngx_array_t *dt; + ngx_connection_t *pc; ngx_http_v3_header_t *h; ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 insert \"%V\":\"%V\"", name, value); + pc = c->qs->parent; + dt = ngx_http_v3_get_dynamic_table(c); if (dt == NULL) { return NGX_ERROR; @@ -201,8 +214,22 @@ ngx_http_v3_insert(ngx_connection_t *c, return NGX_ERROR; } - h->name = *name; - h->value = *value; + h->name.data = ngx_pstrdup(pc->pool, name); + if (h->name.data == NULL) { + h->name.len = 0; + h->value.len = 0; + return NGX_ERROR; + } + + h->name.len = name->len; + + h->value.data = ngx_pstrdup(pc->pool, value); + if (h->value.data == NULL) { + h->value.len = 0; + return NGX_ERROR; + } + + h->value.len = value->len; if (ngx_http_v3_new_header(c) != NGX_OK) { return NGX_ERROR;