]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: qpack: fix buffer API usage on prefix integer encoding
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 May 2022 09:58:06 +0000 (11:58 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 30 May 2022 12:28:46 +0000 (14:28 +0200)
Replace bogus call b_data() by b_room() to check if there is enough
space left in the buffer before encoding a prefix integer.

At this moment, no real scenario was found to trigger a bug related to
this change. This is probably because the buffer always contains data
(field section line and status code) before calling
qpack_encode_prefix_integer() which prevents an occurrence of this bug.

src/qpack-enc.c

index fca2539f4a950283d3c080cc6745453bcd1f82e5..5c4b99f4109a07356c9857d4252fda7ecd064c3e 100644 (file)
@@ -33,13 +33,13 @@ static int qpack_encode_prefix_integer(struct buffer *out, int i, int prefix_siz
        BUG_ON(!prefix_size);
 
        if (i < (1 << prefix_size) - 1) {
-               if (b_data(out) < 1)
+               if (b_room(out) < 1)
                        return 1;
 
                b_putchr(out, before_prefix | i);
        }
        else {
-               if (b_data(out) < 2)
+               if (b_room(out) < 2)
                        return 1;
 
                b_putchr(out, before_prefix | ((1 << prefix_size) - 1));