Welcome! Log In Create A New Profile

Advanced

[PATCH] BUG: payload: fix payload not retrieving arbitrary lengths

Posted by Felipe Guerreiro Barbosa Ruiz 
Felipe Guerreiro Barbosa Ruiz
[PATCH] BUG: payload: fix payload not retrieving arbitrary lengths
March 16, 2017 09:10PM
This fixes a regression introduced in d7bdcb874bcb, that removed the
ability to use req.payload(0,0) to read the whole buffer content. The
offending commit is present starting in version 1.6, so the patch
should be backported to versions 1.6 and 1.7.
---
src/payload.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/payload.c b/src/payload.c
index a02a8696..b80a19c9 100644
--- a/src/payload.c
+++ b/src/payload.c
@@ -838,7 +838,7 @@ smp_fetch_payload(const struct arg *arg_p, struct
sample *smp, const char *kw, v
return 0;

chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ?
&smp->strm->res : &smp->strm->req;
- if (!buf_size || buf_size > global.tune.bufsize || buf_offset +
buf_size > global.tune.bufsize) {
+ if (buf_size > global.tune.bufsize || buf_offset + buf_size >
global.tune.bufsize) {
/* will never match */
smp->flags = 0;
return 0;
Hi Felipe,

On Thu, Mar 16, 2017 at 05:01:41PM -0300, Felipe Guerreiro Barbosa Ruiz wrote:
> This fixes a regression introduced in d7bdcb874bcb, that removed the
> ability to use req.payload(0,0) to read the whole buffer content. The
> offending commit is present starting in version 1.6, so the patch
> should be backported to versions 1.6 and 1.7.

All useful indications are provided, that's perfect, I've applied it now.
Thank you very much Felipe. BTW, just for your information, the patch was
mangled by your mailer (lines were wrapped) but since it was easy I could
fix it by hand :

> diff --git a/src/payload.c b/src/payload.c
> index a02a8696..b80a19c9 100644
> --- a/src/payload.c
> +++ b/src/payload.c
> @@ -838,7 +838,7 @@ smp_fetch_payload(const struct arg *arg_p, struct
> sample *smp, const char *kw, v
> return 0;
>
> chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ?
> &smp->strm->res : &smp->strm->req;
> - if (!buf_size || buf_size > global.tune.bufsize || buf_offset +
> buf_size > global.tune.bufsize) {
> + if (buf_size > global.tune.bufsize || buf_offset + buf_size >
> global.tune.bufsize) {
> /* will never match */
> smp->flags = 0;
> return 0;

Next time, in order to avoid this you can attach the patch to your mail,
mail agents generally don't touch attachments.

Thanks,
Willy
Felipe Guerreiro Barbosa Ruiz
Re: [PATCH] BUG: payload: fix payload not retrieving arbitrary lengths
March 21, 2017 03:30PM
Hi Willy,

Thanks for fixing it. I guess pasting from the terminal straight to gmail
might have caused that. Next time I'll attach it, for sure!

By the way, I noticed the patch was only applied to the latest development
version, but not to 1.6 or 1.7. I'm not sure if it will apply cleanly, but
I can create a patch for each version, if necessary.

Cheers,
Felipe

On 20 March 2017 at 03:30, Willy Tarreau <[email protected]> wrote:

> Hi Felipe,
>
> On Thu, Mar 16, 2017 at 05:01:41PM -0300, Felipe Guerreiro Barbosa Ruiz
> wrote:
> > This fixes a regression introduced in d7bdcb874bcb, that removed the
> > ability to use req.payload(0,0) to read the whole buffer content. The
> > offending commit is present starting in version 1.6, so the patch
> > should be backported to versions 1.6 and 1.7.
>
> All useful indications are provided, that's perfect, I've applied it now.
> Thank you very much Felipe. BTW, just for your information, the patch was
> mangled by your mailer (lines were wrapped) but since it was easy I could
> fix it by hand :
>
> > diff --git a/src/payload.c b/src/payload.c
> > index a02a8696..b80a19c9 100644
> > --- a/src/payload.c
> > +++ b/src/payload.c
> > @@ -838,7 +838,7 @@ smp_fetch_payload(const struct arg *arg_p, struct
> > sample *smp, const char *kw, v
> > return 0;
> >
> > chn = ((smp->opt & SMP_OPT_DIR) == SMP_OPT_DIR_RES) ?
> > &smp->strm->res : &smp->strm->req;
> > - if (!buf_size || buf_size > global.tune.bufsize || buf_offset +
> > buf_size > global.tune.bufsize) {
> > + if (buf_size > global.tune.bufsize || buf_offset + buf_size >
> > global.tune.bufsize) {
> > /* will never match */
> > smp->flags = 0;
> > return 0;
>
> Next time, in order to avoid this you can attach the patch to your mail,
> mail agents generally don't touch attachments.
>
> Thanks,
> Willy
>
On Tue, Mar 21, 2017 at 11:26:15AM -0300, Felipe Guerreiro Barbosa Ruiz wrote:
> Hi Willy,
>
> Thanks for fixing it. I guess pasting from the terminal straight to gmail
> might have caused that. Next time I'll attach it, for sure!
>
> By the way, I noticed the patch was only applied to the latest development
> version, but not to 1.6 or 1.7. I'm not sure if it will apply cleanly, but
> I can create a patch for each version, if necessary.

Don't worry, I'll backport all pending fixes to stable versions. For now I'm
focusing on finishing to merge the remaining pending fixes in order to prepare
a new version.

Willy
Felipe Guerreiro Barbosa Ruiz
Re: [PATCH] BUG: payload: fix payload not retrieving arbitrary lengths
March 21, 2017 04:00PM
Ok, that's brilliant! Thanks a lot!

Cheers,
Felipe

On 21 March 2017 at 11:48, Willy Tarreau <[email protected]> wrote:

> On Tue, Mar 21, 2017 at 11:26:15AM -0300, Felipe Guerreiro Barbosa Ruiz
> wrote:
> > Hi Willy,
> >
> > Thanks for fixing it. I guess pasting from the terminal straight to gmail
> > might have caused that. Next time I'll attach it, for sure!
> >
> > By the way, I noticed the patch was only applied to the latest
> development
> > version, but not to 1.6 or 1.7. I'm not sure if it will apply cleanly,
> but
> > I can create a patch for each version, if necessary.
>
> Don't worry, I'll backport all pending fixes to stable versions. For now
> I'm
> focusing on finishing to merge the remaining pending fixes in order to
> prepare
> a new version.
>
> Willy
>
Sorry, only registered users may post in this forum.

Click here to login