]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: spoe: Be sure the sample is found before setting its context
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 6 May 2019 07:53:10 +0000 (09:53 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 7 May 2019 20:16:41 +0000 (22:16 +0200)
When a sample fetch is encoded, we use its context to set info about the
fragmentation. But if the sample is not found, the function sample_process()
returns NULL. So we me be sure the sample exists before setting its context.

This patch must be backported to 1.9 and 1.8.

include/proto/spoe.h
src/flt_spoe.c

index c840c887b7b89a09270c22b86bae70c2bf141cc8..b3f7b4f8bb73c7098f71c7f61e9c0c3c9f5433b2 100644 (file)
@@ -169,8 +169,8 @@ spoe_encode_data(struct sample *smp, char **buf, char *end)
                         * reamining. When all the sample is encoded, the offset is reset to 0.
                         * So the caller know it can try to encode the next sample. */
                        struct buffer *chk = &smp->data.u.str;
-                       unsigned int *len  = (smp->ctx.a[0] ? smp->ctx.a[0] : 0);
-                       unsigned int *off  = (smp->ctx.a[1] ? smp->ctx.a[1] : 0);
+                       unsigned int *len  = smp->ctx.a[0];
+                       unsigned int *off  = smp->ctx.a[1];
 
                        if (!*off) {
                                /* First evaluation of the sample : encode the
index 75854b7ae31f9fc3b427654a52edd3e40b0a1818..82e2719941060b7b3e3963a85664f7415c53ecd5 100644 (file)
@@ -2195,8 +2195,10 @@ spoe_encode_message(struct stream *s, struct spoe_context *ctx,
 
                /* Fetch the argument value */
                smp = sample_process(s->be, s->sess, s, dir|SMP_OPT_FINAL, arg->expr, NULL);
-               smp->ctx.a[0] = &ctx->frag_ctx.curlen;
-               smp->ctx.a[1] = &ctx->frag_ctx.curoff;
+               if (smp) {
+                       smp->ctx.a[0] = &ctx->frag_ctx.curlen;
+                       smp->ctx.a[1] = &ctx->frag_ctx.curoff;
+               }
                ret = spoe_encode_data(smp, buf, end);
                if (ret == -1 || ctx->frag_ctx.curoff)
                        goto too_big;