From: Gihyeon Ryu Date: Wed, 11 Nov 2026 10:00:12 +0000 (+0000) Subject: BUG/MINOR: sample: fix host_only and port_only on empty input X-Git-Tag: v3.5-dev13~80 X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/gitweb.js?a=commitdiff_plain;h=42ef0b23e5e0761f1546a83ecc73c8035dc003a0;p=haproxy.git BUG/MINOR: sample: fix host_only and port_only on empty input sample_conv_host_only() and sample_conv_port_only() scan backwards from area + data - 1. With an empty sample whose area is NULL, as returned by req.body for a request without a body, this pointer is (char *)-1, the first dereference faults and the worker dies (SIGSEGV, also in release builds). A configuration applying these converters to req.body can thus be stopped by a plain "GET /". Both converters now return early on an empty input, with an empty string and 0 respectively. This should be backported to 2.8 and later. --- diff --git a/src/sample.c b/src/sample.c index 877e8e02c..548d8c232 100644 --- a/src/sample.c +++ b/src/sample.c @@ -4152,6 +4152,12 @@ static int sample_conv_host_only(const struct arg *arg_p, struct sample *smp, vo char *end = smp->data.u.str.area + smp->data.u.str.data - 1; char *p; + /* an empty input may come with a NULL area */ + if (!smp->data.u.str.data) { + smp->data.type = SMP_T_STR; + return 1; + } + for (p = end; p >= beg; p--) { if (*p == ':' || *p == ']') break; @@ -4178,6 +4184,13 @@ static int sample_conv_port_only(const struct arg *arg_p, struct sample *smp, vo char *end = smp->data.u.str.area + smp->data.u.str.data - 1; char *p; + /* see sample_conv_host_only() */ + if (!smp->data.u.str.data) { + smp->data.type = SMP_T_SINT; + smp->data.u.sint = 0; + return 1; + } + for (p = end; p >= beg; p--) { if (*p == ':' || *p == ']') break;