diff --git a/src/quic_frame.c b/src/quic_frame.c index 89640f334..d80eb5ac4 100644 --- a/src/quic_frame.c +++ b/src/quic_frame.c @@ -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;