]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: sample: check alloc_trash_chunk return value in concat()
authorWilliam Dauchy <wdauchy@gmail.com>
Mon, 11 Jan 2021 10:05:58 +0000 (11:05 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 11 Jan 2021 13:10:11 +0000 (14:10 +0100)
like it is done in other places, check the return value of
`alloc_trash_chunk` before using it. This was detected by coverity.

this patch fixes commit 591fc3a330005c289b4705fe4cb37c4eec9f9eed
("BUG/MINOR: sample: fix concat() converter's corruption with non-string
variables"
As a consequence, this patch should be backported as far as 2.0

this should fix github issue #1039

Signed-off-by: William Dauchy <wdauchy@gmail.com>
src/sample.c

index fa854632f4ea34fa88fbccb9220cd4003d74234f..7e4a0d06092dea73808b650560b7b550bda1e76b 100644 (file)
@@ -2992,6 +2992,9 @@ static int sample_conv_concat(const struct arg *arg_p, struct sample *smp, void
        int max;
 
        trash = alloc_trash_chunk();
+       if (!trash)
+               return 0;
+
        trash->data = smp->data.u.str.data;
        if (trash->data > trash->size - 1)
                trash->data = trash->size - 1;