]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: quic: Missing random bits in Retry packet header
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 30 Jun 2023 10:17:36 +0000 (12:17 +0200)
committerFrédéric Lécaille <flecaille@haproxy.com>
Fri, 30 Jun 2023 10:17:36 +0000 (12:17 +0200)
The 4 bits least significant bits of the first byte in a Retry packet must be
random. There are generated calling statistical_prng_range() with 16 as argument.

Must be backported as far as 2.6.

src/quic_conn.c

index caf04a2446ca09fd6ede8118ce4c95ce7beb429e..9ecce919733545d4e386f08111e223e8beb848bf 100644 (file)
@@ -6641,9 +6641,10 @@ static int send_retry(int fd, struct sockaddr_storage *addr,
 
        TRACE_ENTER(QUIC_EV_CONN_TXPKT);
 
-       /* long header + fixed bit + packet type QUIC_PACKET_TYPE_RETRY */
+       /* long header(1) | fixed bit(1) | packet type QUIC_PACKET_TYPE_RETRY(2) | unused random bits(4)*/
        buf[i++] = (QUIC_PACKET_LONG_HEADER_BIT | QUIC_PACKET_FIXED_BIT) |
-               (quic_pkt_type(QUIC_PACKET_TYPE_RETRY, qv->num) << QUIC_PACKET_TYPE_SHIFT);
+               (quic_pkt_type(QUIC_PACKET_TYPE_RETRY, qv->num) << QUIC_PACKET_TYPE_SHIFT) |
+               statistical_prng_range(16);
        /* version */
        buf[i++] = *((unsigned char *)&qv->num + 3);
        buf[i++] = *((unsigned char *)&qv->num + 2);