diff --git a/src/mux_quic.c b/src/mux_quic.c index 98737367e..fe33e4d51 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -1436,6 +1436,7 @@ static int qcs_build_stream_frm(struct qcs *qcs, struct buffer *out, char fin, frm->stream.id = qcs->id; frm->stream.buf = out; frm->stream.data = (unsigned char *)b_peek(out, head); + frm->stream.offset.key = 0; /* FIN is positioned only when the buffer has been totally emptied. */ if (fin) diff --git a/src/quic_conn.c b/src/quic_conn.c index 26a75f563..a64cd654d 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -6857,8 +6857,7 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist, new_cf->stream.stream = cf->stream.stream; new_cf->stream.buf = cf->stream.buf; new_cf->stream.id = cf->stream.id; - if (cf->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT) - new_cf->stream.offset = cf->stream.offset; + new_cf->stream.offset = cf->stream.offset; new_cf->stream.len = dlen; new_cf->type |= QUIC_STREAM_FRAME_TYPE_LEN_BIT; /* FIN bit reset */ diff --git a/src/quic_frame.c b/src/quic_frame.c index 6f299ba2d..0d8bc87f5 100644 --- a/src/quic_frame.c +++ b/src/quic_frame.c @@ -507,6 +507,10 @@ static int quic_build_stream_frame(unsigned char **buf, const unsigned char *end struct quic_stream *stream = &frm->stream; const unsigned char *wrap; + /* Caller must set OFF bit if and only if a non-null offset is used. */ + BUG_ON(!!(frm->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT) != + !!stream->offset.key); + if (!quic_enc_int(buf, end, stream->id) || ((frm->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT) && !quic_enc_int(buf, end, stream->offset.key)) || ((frm->type & QUIC_STREAM_FRAME_TYPE_LEN_BIT) &&