From a265735ddd7427bef01f5d1996cc722ba9991132 Mon Sep 17 00:00:00 2001 From: Andrey Kolyshkin Date: Mon, 10 Jul 2023 16:34:46 +0300 Subject: [PATCH] Fixed segfault in ngx_http_find_virtual_server() within xquic module A segfault was corrected when calling ngx_http_find_virtual_server in the xquic module. The issue originated from c->data being taken as ngx_http_connection_t while regular expressions were in use. However, for http3 connections, c->data is a pointer to ngx_http_xquic_connection_t --- modules/ngx_http_xquic_module/ngx_http_xquic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/ngx_http_xquic_module/ngx_http_xquic.c b/modules/ngx_http_xquic_module/ngx_http_xquic.c index 470366454c..088e6c0ef4 100644 --- a/modules/ngx_http_xquic_module/ngx_http_xquic.c +++ b/modules/ngx_http_xquic_module/ngx_http_xquic.c @@ -207,6 +207,9 @@ ngx_http_v3_cert_cb(const char *sni, void **chain, } #endif + /* The ngx_http_find_virtual_server() function requires ngx_http_connection_t in c->data */ + c->data = hc; + /* * get the server core conf by sni, this is useful when multiple server * block listen on the same port. but useless when there is noly a single @@ -214,6 +217,8 @@ ngx_http_v3_cert_cb(const char *sni, void **chain, */ ret = ngx_http_find_virtual_server_inner(c, hc->addr_conf->virtual_names, &host, NULL, &cscf); + c->data = qc; + if (ret == NGX_OK) { hc->ssl_servername = ngx_palloc(c->pool, sizeof(ngx_str_t)); if (hc->ssl_servername == NULL) {