From 8bd835b2d28b978ce19a27f4ea57b8cecb126bcf Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 20 Jun 2023 13:34:46 +0200 Subject: [PATCH] MEDIUM: filters/htx: Don't rely on HTX extra field if payload is filtered If an HTTP data filter is registered on a channel, we must not rely on the HTX extra field because the payload may be changed and we cannot predict if this value will change or not. It is too errorprone to let filters deal with this reponsibility. So we set it to 0 when payload filtering is performed, but only if the payload length can be determined. It is important because this field may be used when data are forwarded. In fact, it will be used by the H1 multiplexer to be able to splice chunk-encoded payload. --- src/filters.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/filters.c b/src/filters.c index 8910fc2684..e55adee6b4 100644 --- a/src/filters.c +++ b/src/filters.c @@ -655,6 +655,7 @@ int flt_http_payload(struct stream *s, struct http_msg *msg, unsigned int len) { struct filter *filter; + struct htx *htx; unsigned long long *strm_off = &FLT_STRM_OFF(s, msg->chn); unsigned int out = co_data(msg->chn); int ret, data; @@ -702,6 +703,9 @@ flt_http_payload(struct stream *s, struct http_msg *msg, unsigned int len) ret = data; *strm_off += ret; end: + htx = htxbuf(&msg->chn->buf); + if (msg->flags & HTTP_MSGF_XFER_LEN) + htx->extra = 0; DBG_TRACE_LEAVE(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s); return ret; } -- 2.39.5