]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: htx: Adjust length to add DATA block in an empty HTX buffer
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 12 Jan 2022 13:03:42 +0000 (14:03 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 13 Jan 2022 08:34:22 +0000 (09:34 +0100)
htx_add_data() is able to partially consume data. However there is a bug
when the HTX buffer is empty.  The data length is not properly
adjusted. Thus, if it exceeds the HTX buffer size, no block is added. To fix
the issue, the length is now adjusted first.

This patch must be backported as far as 2.0.

src/htx.c

index 940989c5083634d5e05b9fe2aa33301a75890861..3cc1a34b05bf9d7598176a6ea2534720d9abe8a2 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -939,9 +939,6 @@ size_t htx_add_data(struct htx *htx, const struct ist data)
        uint32_t sz, room;
        int32_t len = data.len;
 
-       if (htx->head == -1)
-               goto add_new_block;
-
        /* Not enough space to store data */
        if (len > htx_free_data_space(htx))
                len = htx_free_data_space(htx);
@@ -949,6 +946,9 @@ size_t htx_add_data(struct htx *htx, const struct ist data)
        if (!len)
                return 0;
 
+       if (htx->head == -1)
+               goto add_new_block;
+
        /* get the tail and head block */
        tailblk = htx_get_tail_blk(htx);
        if (tailblk == NULL)