]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: ensure txbuf realloc is only performed on empty buffer
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 1 Oct 2024 08:55:40 +0000 (10:55 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 1 Oct 2024 09:51:51 +0000 (11:51 +0200)
QUIC application protocol layer has the ability to either allocate a
standard buffer or a smaller one. The latter is useful when only small
data are transferred to prevent consuming too much of the QUIC MUX
buffer window.

This operation is performed using qc_stream_buf_realloc(). Add a new
BUG_ON() in it to ensure no data is present in the buffer. Indeed, this
would cause to data loss, or even crash when trying to acknowledge data.

Note that for the moment qc_stream_buf_realloc() is only use for HTTP/3
headers transmission, and this usage is conform to the new BUG_ON. This
commit is thus not a bug fix, but only to strengthen the API.

src/quic_stream.c

index bf9a54e620c0a6b36a640e8ad379667a06621671..7181e003461eec8cc0add1ae6daff1e10a47425d 100644 (file)
@@ -325,6 +325,9 @@ struct buffer *qc_stream_buf_realloc(struct qc_stream_desc *stream)
        /* This function is reserved to convert a big buffer to a smaller one. */
        BUG_ON(!stream->buf || !stream->buf->sbuf);
 
+       /* This function can only be used if targetted buffer is empty. */
+       BUG_ON(b_data(&stream->buf->buf));
+
        /* Release buffer */
        pool_free(pool_head_sbuf, stream->buf->buf.area);
        stream->buf->buf = BUF_NULL;