# HG changeset patch # User Roman Arutyunyan # Date 1584181135 -10800 # Node ID 1307308c3cf1b318ddc45f213496277487cef3da # Parent 33feac1e57ac58578afbb3fa2f476c7597158263 Temporary fix for header null-termination in HTTP/3. diff -r 33feac1e57ac -r 1307308c3cf1 src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c Sat Mar 14 03:15:09 2020 +0300 +++ b/src/http/ngx_http_request.c Sat Mar 14 13:18:55 2020 +0300 @@ -1547,11 +1547,11 @@ h->key.len = r->header_name_end - r->header_name_start; h->key.data = r->header_name_start; - //h->key.data[h->key.len] = '\0'; + h->key.data[h->key.len] = '\0'; h->value.len = r->header_end - r->header_start; h->value.data = r->header_start; - //h->value.data[h->value.len] = '\0'; + h->value.data[h->value.len] = '\0'; h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); if (h->lowcase_key == NULL) { diff -r 33feac1e57ac -r 1307308c3cf1 src/http/v3/ngx_http_v3_request.c --- a/src/http/v3/ngx_http_v3_request.c Sat Mar 14 03:15:09 2020 +0300 +++ b/src/http/v3/ngx_http_v3_request.c Sat Mar 14 13:18:55 2020 +0300 @@ -518,6 +518,18 @@ } } + /* XXX ugly reallocation for the trailing '\0' */ + + p = ngx_pnalloc(c->pool, name.len + value.len + 2); + if (p == NULL) { + return NGX_ERROR; + } + + ngx_memcpy(p, name.data, name.len); + name.data = p; + ngx_memcpy(p + name.len + 1, value.data, value.len); + value.data = p + name.len + 1; + ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 header \"%V\":\"%V\"", &name, &value);