BUG/MINOR: mux-quic: do not signal FIN if gap in buffer

Adjust FIN signal on Rx path for the application layer : ensure that the
receive buffer has no gap.

Without this extra condition, FIN was signalled as soon as the STREAM
frame with FIN was received, even if we were still waiting to receive
missing offsets.

This bug could have lead to incomplete requests read from the
application protocol. However, in practice this bug has very little
chance to happen as the application layer ensures that the demuxed frame
length is equivalent to the buffer data size. The only way to happen is
if to receive the FIN STREAM as the H3 demuxer is still processing on a
frame which is not the last one of the stream.

This must be backported up to 2.6. The previous patch on ncbuf is
required for the newly defined function ncb_is_fragmented().
  MINOR: ncbuf: implement ncb_is_fragmented()
This commit is contained in:
Amaury Denoyelle 2022-07-01 11:26:04 +02:00
parent e0a92a7e56
commit 6befccd8a1

View File

@ -439,11 +439,19 @@ static int qcc_decode_qcs(struct qcc *qcc, struct qcs *qcs)
{
struct buffer b;
ssize_t ret;
int fin = 0;
TRACE_ENTER(QMUX_EV_QCS_RECV, qcc->conn, qcs);
b = qcs_b_dup(&qcs->rx.ncbuf);
ret = qcc->app_ops->decode_qcs(qcs, &b, qcs->flags & QC_SF_FIN_RECV);
/* Signal FIN to application if STREAM FIN received and there is no gap
* in the Rx buffer.
*/
if (qcs->flags & QC_SF_FIN_RECV && !ncb_is_fragmented(&qcs->rx.ncbuf))
fin = 1;
ret = qcc->app_ops->decode_qcs(qcs, &b, fin);
if (ret < 0) {
TRACE_DEVEL("leaving on decoding error", QMUX_EV_QCS_RECV, qcc->conn, qcs);
return 1;