BUG/MINOR: filters: Use filter offset to decude the amount of forwarded data
When the tcp or http payload is filtered, it is important to use the filter
offset to decude the amount of forwarded data because this offset may change
during the call to the callback function. So we should not rely on a local
variable defined before this call.
For now, existing HAproxy filters don't change this offset, so this bug may only
affect external filters.
This patch must be forwarded as far as 1.9.
(cherry picked from commit c50ee0b3b4001300f47f77bbdc38b2991b76d663)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 38c5bcf3eca7b47a5ef7ec87a9406ae441936762)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
[Cf: Only the HTTP callback function was changed because the TCP part is not the
same and still use the old forwarding mechanism. ]
diff --git a/src/filters.c b/src/filters.c
index 47982a4..8ca4446 100644
--- a/src/filters.c
+++ b/src/filters.c
@@ -796,8 +796,8 @@
ret = FLT_OPS(filter)->http_payload(s, filter, msg, out + offset, data - offset);
if (ret < 0)
goto end;
+ data = ret + *flt_off - *strm_off;
*flt_off += ret;
- data = ret + offset;
}
}