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.3-dev5~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2414a23c4c20b14c54ee9279e99fb96c81a29b1;p=thirdparty%2Fhaproxy.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. --- diff --git a/src/http_fetch.c b/src/http_fetch.c index 0a29c810ae..170d86c238 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -217,7 +217,6 @@ struct htx *smp_prefetch_htx(struct sample *smp, struct channel *chn, struct che } 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); @@ -315,7 +314,6 @@ struct htx *smp_prefetch_htx(struct sample *smp, struct channel *chn, struct che /* everything's OK */ end: - smp->data.u.sint = 1; return htx; }