aboutsummaryrefslogtreecommitdiff
path: root/src/http/v3/ngx_http_v3_tables.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2020-05-14 16:02:32 +0300
committerRoman Arutyunyan <arut@nginx.com>2020-05-14 16:02:32 +0300
commit097d8a87b3f8c0d4f12cc468d35a590ae18e81ed (patch)
tree64de296bd0e5194c794a2dc0cfd733cc26fa6778 /src/http/v3/ngx_http_v3_tables.c
parent94764fda6efa48fc18b2fc0a2cd82d451e947094 (diff)
downloadnginx-097d8a87b3f8c0d4f12cc468d35a590ae18e81ed.tar.gz
nginx-097d8a87b3f8c0d4f12cc468d35a590ae18e81ed.zip
HTTP/3: reallocate strings inserted into the dynamic table.
They should always be allocated from the main QUIC connection pool.
Diffstat (limited to 'src/http/v3/ngx_http_v3_tables.c')
-rw-r--r--src/http/v3/ngx_http_v3_tables.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/http/v3/ngx_http_v3_tables.c b/src/http/v3/ngx_http_v3_tables.c
index f58f190f1..ecebe943c 100644
--- 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 *c, ngx_uint_t dynamic,
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 *c, ngx_uint_t dynamic,
}
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 *name,
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, ngx_str_t *name,
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;