]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: quic: Wrong reuse of fulfilled dgram RX buffer
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 23 Jun 2022 15:47:10 +0000 (17:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 23 Jun 2022 18:39:19 +0000 (20:39 +0200)
After having fulfilled a buffer, then marked it as full, we must
consume the remaining space. But to do that, and not to erase the
already existing data, we must check there is not remaining data in
after the tail of the buffer (between the tail and the head).
This is done adding a condition to test that adding the number of
bytes from the remaining contiguous space to the tail does not
pass the wrapping postion in the buffer.

Must be backported to 2.6.

src/quic_sock.c

index a391006aff020bd6e03617374a527011c5eacb9e..4444ab8587a334017ea0fbaabf22062e2df4205d 100644 (file)
@@ -310,6 +310,12 @@ void quic_sock_fd_iocb(int fd)
        if (cspace < max_sz) {
                struct quic_dgram *dgram;
 
+               /* Do no mark <buf> as full, and do not try to consume it
+                * if the contiguous remmaining space is not at the end
+                */
+               if (b_tail(buf) + cspace < b_wrap(buf))
+                       goto out;
+
                /* Allocate a fake datagram, without data to locate
                 * the end of the RX buffer (required during purging).
                 */
@@ -319,11 +325,11 @@ void quic_sock_fd_iocb(int fd)
 
                dgram->len = cspace;
                LIST_APPEND(&rxbuf->dgrams, &dgram->list);
+
                /* Consume the remaining space */
                b_add(buf, cspace);
                if (b_contig_space(buf) < max_sz)
                        goto out;
-
        }
 
        dgram_buf = (unsigned char *)b_tail(buf);