From: Christopher Faulet Date: Fri, 18 Sep 2020 08:19:02 +0000 (+0200) Subject: BUG/MINOR: http-fetch: Don't set the sample type during the htx prefetch X-Git-Tag: v2.1.9~14 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=99901e5ccca7ac217c1ea9d86ab41da859e43c94;p=haproxy-2.1.git BUG/MINOR: http-fetch: Don't set the sample type during the htx prefetch A subtle bug was introduced by the commit a6d9879e6 ("BUG/MEDIUM: htx: smp_prefetch_htx() must always validate the direction"), for the "method" sample fetch only. The sample data type and the method id are always overwritten because smp_prefetch_htx() function is called later in the sample fetch evaluation. The bug is in the smp_prefetch_htx() function but it is only visible for the "method" sample fetch, for an unknown method. In fact, when smp_prefetch_htx() is called, the sample object is altered. The data type is set to SMP_T_BOOL and, on success, the data value is set to 1. Thus, if the caller has already set some infos into the sample object, they may be lost. AFAIK, there is no reason to do so. It is inherited from the legacy HTTP code and I honestely don't known why it was done this way. So, instead of fixing the "method" sample fetch to set useful info after the call to smp_prefetch_htx() function, I prefer to not alter the sample object in smp_prefetch_htx(). This patch must be backported as far as 2.0. On the 2.0, only the HTX part must be fixed. (cherry picked from commit d2414a23c4c20b14c54ee9279e99fb96c81a29b1) Signed-off-by: Willy Tarreau (cherry picked from commit b8aa5f28cea612eadfbd6d775d8402e45a6547c6) [wt: adjusted ctx] Signed-off-by: Willy Tarreau --- diff --git a/src/http_fetch.c b/src/http_fetch.c index 738cc30..2ade565 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -198,7 +198,6 @@ struct htx *smp_prefetch_htx(struct sample *smp, struct channel *chn, int vol) } txn = s->txn; msg = (!(chn->flags & CF_ISRESP) ? &txn->req : &txn->rsp); - smp->data.type = SMP_T_BOOL; if (IS_HTX_STRM(s)) { htx = htxbuf(&chn->buf); @@ -295,7 +294,6 @@ struct htx *smp_prefetch_htx(struct sample *smp, struct channel *chn, int vol) } /* everything's OK */ - smp->data.u.sint = 1; return htx; }