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.
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;
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;