Hi,
Here are 2 patches to fix bi_putblk and bo_putblk in the wrapping case.
There are 2 patches because the one about bo_putblk must be backported
to haproxy 1.5 and newer versions while the one about bi_putblk must
only be backported to 1.8. But the fix is the same.
Thanks
--
Christopher Faulet
>From 5d4575a2f8dcd1d8b75134c0d99178173e0d056e Mon Sep 17 00:00:00 2001
From: Christopher Faulet <[email protected]>
Date: Mon, 26 Feb 2018 10:47:03 +0100
Subject: [PATCH 1/2] BUG/MEDIUM: buffer: Fix the wrapping case in bo_putblk
When the block of data need to be split to support the wrapping, the start of
the second block of data was wrong. We must be sure to skip data copied during
the first memcpy.
This patch must be backported to 1.8, 1.7, 1.6 and 1.5.
---
include/common/buffer.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/common/buffer.h b/include/common/buffer.h
index c92029836..4adfdc647 100644
--- a/include/common/buffer.h
+++ b/include/common/buffer.h
@@ -468,7 +468,7 @@ static inline int bo_putblk(struct buffer *b, const char *blk, int len)
memcpy(b->p, blk, half);
b->p = b_ptr(b, half);
if (len > half) {
- memcpy(b->p, blk, len - half);
+ memcpy(b->p, blk + half, len - half);
b->p = b_ptr(b, half);
}
b->o += len;
--
2.14.3
>From 18c3368cfd67e0d62bb6a4b29a562549a41aef4e Mon Sep 17 00:00:00 2001
From: Christopher Faulet <[email protected]>
Date: Mon, 26 Feb 2018 10:51:28 +0100
Subject: [PATCH 2/2] BUG/MEDIUM: buffer: Fix the wrapping case in bi_putblk
When the block of data need to be split to support the wrapping, the start of
the second block of data was wrong. We must be sure to skup data copied during
the first memcpy.
This patch must be backported to 1.8.
---
include/common/buffer.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/common/buffer.h b/include/common/buffer.h
index 4adfdc647..7ac98bf0d 100644
--- a/include/common/buffer.h
+++ b/include/common/buffer.h
@@ -577,7 +577,7 @@ static inline int bi_putblk(struct buffer *b, const char *blk, int len)
memcpy(bi_end(b), blk, half);
if (len > half)
- memcpy(b_ptr(b, b->i + half), blk, len - half);
+ memcpy(b_ptr(b, b->i + half), blk + half, len - half);
b->i += len;
return len;
}
--
2.14.3