]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: htx: Never transfer more than expected in htx_xfer_blks()
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 7 May 2019 08:52:25 +0000 (10:52 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 7 May 2019 20:16:41 +0000 (22:16 +0200)
When the maximum free space available for data in the HTX message is compared to
the number of bytes to transfer, we must take into account the amount of data
already transferred. Otherwise we may move more data than expected.

This patch must be backported to 1.9.

src/htx.c

index b18ce5f6755aef34696fa4c35532411d2f87d05a..a98a3080c89a030b77de800a733a819b88744305 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -516,8 +516,8 @@ struct htx_ret htx_xfer_blks(struct htx *dst, struct htx *src, uint32_t count,
 
                info = blk->info;
                max = htx_free_data_space(dst);
-               if (max > count)
-                       max = count;
+               if (max > count - ret)
+                       max = count - ret;
                if (sz > max) {
                        sz = max;
                        info = (type << 28) + sz;