BUG/MEDIUM: capture: capture-req/capture-res converters crash without a stream
Since commit 5f940703b3 ("MINOR: log: Don't depends on a stream to process
samples in log-format string") it has become quite obvious that a few sample
fetch functions and converters were still heavily dependent on the presence
of a stream without testing for it.
The capture-req and capture-res converters were in this case and could
crash the process if misused.
This fix adds a check for the stream's existence, and should be backported
to all stable versions up to 1.6.
(cherry picked from commit 5575896ba1120f136e680fd669afb5b084faa530)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 909523621f634a8d8a1e70a3a5024238dc313b0d)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/http_conv.c b/src/http_conv.c
index 803d7bc..cef5254 100644
--- a/src/http_conv.c
+++ b/src/http_conv.c
@@ -247,7 +247,7 @@
static int smp_conv_req_capture(const struct arg *args, struct sample *smp, void *private)
{
- struct proxy *fe = strm_fe(smp->strm);
+ struct proxy *fe;
int idx, i;
struct cap_hdr *hdr;
int len;
@@ -255,6 +255,10 @@
if (!args || args->type != ARGT_SINT)
return 0;
+ if (!smp->strm)
+ return 0;
+
+ fe = strm_fe(smp->strm);
idx = args->data.sint;
/* Check the availibity of the capture id. */
@@ -288,7 +292,7 @@
static int smp_conv_res_capture(const struct arg *args, struct sample *smp, void *private)
{
- struct proxy *fe = strm_fe(smp->strm);
+ struct proxy *fe;
int idx, i;
struct cap_hdr *hdr;
int len;
@@ -296,6 +300,10 @@
if (!args || args->type != ARGT_SINT)
return 0;
+ if (!smp->strm)
+ return 0;
+
+ fe = strm_fe(smp->strm);
idx = args->data.sint;
/* Check the availibity of the capture id. */