BUG/MINOR: sample: fix concat() converter's corruption with non-string variables
authorWilly Tarreau <w@1wt.eu>
Fri, 8 Jan 2021 15:08:43 +0000 (16:08 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 8 Jan 2021 15:08:43 +0000 (16:08 +0100)
commit591fc3a330005c289b4705fe4cb37c4eec9f9eed
tree7e1ba35aa51247491cf357e1cb1981594e68e059
parent84c88a58c5153b8fffa509934375c92435298a1b
BUG/MINOR: sample: fix concat() converter's corruption with non-string variables

Patrick Hemmer reported that calling concat() with an integer variable
causes a %00 to appear at the beginning of the output. Looking at the
code, it's not surprising. The function uses get_trash_chunk() to get
one of the trashes, but can call casting functions which will also use
their trash in turn and will cycle back to ours, causing the trash to
be overwritten before being assigned to a sample.

By allocating the trash from a pool using alloc_trash_chunk(), we can
avoid this. However we must free it so the trash's contents must be
moved to a permanent trash buffer before returning. This is what's
achieved using smp_dup().

This should be backported as far as 2.0.
src/sample.c