Re: [PATCH] BUG/MEDIUM: sample: Fix adjusting size in word converter

2022-05-27 Thread Willy Tarreau
On Wed, May 25, 2022 at 10:58:51PM -0600, astrotha...@gmail.com wrote:
> From: Thayne McCombs 
> 
> Adjust the size of the sample buffer before we change the "area"
> pointer. Otherwise, we end up not changing the size, because the area
> pointer is already the same as "start" before we compute the difference
> between the two.
> 
> This is similar to the change in b28430591d18f7fda5bac2e0ea590b3a34f04601
> but for the word converter instead of field.

Good catch, now merged, thank you Thayne!
Willy



[PATCH] BUG/MEDIUM: sample: Fix adjusting size in word converter

2022-05-25 Thread astrothayne
From: Thayne McCombs 

Adjust the size of the sample buffer before we change the "area"
pointer. Otherwise, we end up not changing the size, because the area
pointer is already the same as "start" before we compute the difference
between the two.

This is similar to the change in b28430591d18f7fda5bac2e0ea590b3a34f04601
but for the word converter instead of field.
---
 src/sample.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/sample.c b/src/sample.c
index 8a0a66b8c..50ae76b6e 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -2596,13 +2596,14 @@ static int sample_conv_word(const struct arg *arg_p, 
struct sample *smp, void *p
if (!smp->data.u.str.data)
return 1;
 
-   smp->data.u.str.area = start;
 
/* Compute remaining size if needed
Note: smp->data.u.str.size cannot be set to 0 */
if (smp->data.u.str.size)
smp->data.u.str.size -= start - smp->data.u.str.area;
 
+   smp->data.u.str.area = start;
+
return 1;
 }
 
-- 
2.36.1