]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-h1: make sure we always have at least one HTX block to send
authorWilly Tarreau <w@1wt.eu>
Sat, 15 Dec 2018 13:48:31 +0000 (14:48 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 15 Dec 2018 13:48:31 +0000 (14:48 +0100)
Commit 84cca66 ("BUG/MEDIUM: htx: When performing zero-copy, start from
the right offset.") uncovered another issue which is that the send function
may occasionally be called without any block. It's important to check for
this case when computing the zero-copy offsets.

No backport is needed.

src/mux_h1.c

index 32004c68c4f604bcf3ef5913bd5b226db8c4f2de..09c29c2f02969dc7ab33a9814870b6c81a80af3d 100644 (file)
@@ -1367,7 +1367,10 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
 
        if (!count)
                goto end;
+
        chn_htx = htx_from_buf(buf);
+       if (htx_is_empty(chn_htx))
+               goto end;
 
        if (!h1_get_buf(h1c, &h1c->obuf)) {
                h1c->flags |= H1C_F_OUT_ALLOC;
@@ -1383,6 +1386,7 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
                errflag = H1S_F_REQ_ERROR;
        }
 
+       /* the htx is non-empty thus has at least one block */
        blk = htx_get_head_blk(chn_htx);
 
        tmp = get_trash_chunk();
@@ -1407,7 +1411,7 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
                h1c->obuf.head = sizeof(struct htx) + blk->addr;
 
                if (chn_htx->used == 1 &&
-                   blk && htx_get_blk_type(blk) == HTX_BLK_DATA &&
+                   htx_get_blk_type(blk) == HTX_BLK_DATA &&
                    htx_get_blk_value(chn_htx, blk).len == count) {
                        void *old_area = h1c->obuf.area;