]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: quic: Wrong Retry paquet version field endianess
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 30 Jun 2023 12:41:31 +0000 (14:41 +0200)
committerFrédéric Lécaille <flecaille@haproxy.com>
Fri, 30 Jun 2023 12:41:31 +0000 (14:41 +0200)
The 32-bits version field of the Retry paquet was inversed by the code. As this
field must be in the network byte order on the wire, this code has supposed that
the sender of the Retry packet will always be little endian. Hopefully this is
often the case on our Intel machines ;)

Must be backported as far as 2.6.

src/quic_conn.c

index 9ecce919733545d4e386f08111e223e8beb848bf..6be031717da028b4fef46969b0fb03c507f95f18 100644 (file)
@@ -6646,10 +6646,8 @@ static int send_retry(int fd, struct sockaddr_storage *addr,
                (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);
-       buf[i++] = *((unsigned char *)&qv->num + 1);
-       buf[i++] = *(unsigned char *)&qv->num;
+       *(uint32_t *)&buf[i] = htonl(qv->num);
+       i += sizeof(uint32_t);
 
        /* Use the SCID from <pkt> for Retry DCID. */
        buf[i++] = pkt->scid.len;