]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: quic: Wrong STREAM frames parsing.
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 31 Dec 2020 09:57:04 +0000 (10:57 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 4 Jan 2021 11:31:28 +0000 (12:31 +0100)
After having re-read the RFC, we noticed there are two bugs in the STREAM
frame parser. When the OFF bit (0x04) in the frame type is not set
we must set the offset to 0 (it was not set at all). When the LEN bit (0x02)
is not set we must extend the length of the data field to the end of the packet
(it was not set at all).

src/quic_frame.c

index 89640f334dc044a045c69175a50ad8b4803878b7..d80eb5ac4ef6b0015e286bc4e4583115cc04ffec 100644 (file)
@@ -396,10 +396,21 @@ static int quic_parse_stream_frame(struct quic_frame *frm, struct quic_conn *qc,
 {
        struct quic_stream *stream = &frm->stream;
 
-       if (!quic_dec_int(&stream->id, buf, end) ||
-           ((frm->type & QUIC_STREAM_FRAME_OFF_BIT) && !quic_dec_int(&stream->offset, buf, end)) ||
-           ((frm->type & QUIC_STREAM_FRAME_LEN_BIT) &&
-            (!quic_dec_int(&stream->len, buf, end) || end - *buf < stream->len)))
+       if (!quic_dec_int(&stream->id, buf, end))
+               return 0;
+
+       /* Offset parsing */
+       if (!(frm->type & QUIC_STREAM_FRAME_OFF_BIT)) {
+               stream->offset = 0;
+       }
+       else if (!quic_dec_int(&stream->offset, buf, end))
+               return 0;
+
+       /* Length parsing */
+       if (!(frm->type & QUIC_STREAM_FRAME_LEN_BIT)) {
+               stream->len = end - *buf;
+       }
+       else if (!quic_dec_int(&stream->len, buf, end) || end - *buf < stream->len)
                return 0;
 
        stream->data = *buf;