BUG/MEDIUM: sample: Fix adjusting size in field converter
authorThayne McCombs <astrothayne@gmail.com>
Mon, 12 Apr 2021 05:26:59 +0000 (23:26 -0600)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 29 Apr 2021 09:05:04 +0000 (11:05 +0200)
commit1b9bc2dbdc3e894cce4b95dd8e238818746566ad
treea3bef4ff6f1386714603db8637497273b168ee3e
parentb539fadc60b308950fbfa82f77f3a11621d3f0b8
BUG/MEDIUM: sample: Fix adjusting size in field converter

Adjust the size of the sample buffer before we change the "area"
pointer. The change in size is calculated as the difference between the
original pointer and the new start pointer. But since the
`smp->data.u.str.area` assignment results in `smp->data.u.str.area` and
`start` being the same pointer, we always ended up substracting zero.
This changes it to change the size by the actual amount it changed.

I'm not entirely sure what the impact of this is, but the previous code
seemed wrong.

[wt: from what I can see the only harmful case is when the output is
 converted to a stick-table key, it could result in zeroing past the
 end of the buffer; other cases do not touch beyond ->data]

(cherry picked from commit b28430591d18f7fda5bac2e0ea590b3a34f04601)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit ffa784670629113faa33aa9f035d8f15225ce183)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit eec34f5dba71f59ea83a1f03ab11f98a94165448)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/sample.c