From 98064537423fafe05b9ddd97e81cedec8b6b278d Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Tue, 31 Dec 2024 15:21:19 +0100 Subject: [PATCH] BUG/MAJOR: mux-quic: fix BUG_ON on empty STREAM emission A BUG_ON() is present in qcc_io_send() to ensure that encoded frame list is empty if qcc_build_frms() previously returned 0. This BUG_ON() may be triggered if empty STREAM frame is encoded for standalone FIN. Indeed, qcc_build_frms() returns the sum of all STREAM payload length. In case only empty STREAM frames are generated, return value will be 0, despite new frames encoded and inserted into frame list. To fix this, change return value of qcs_send(). This now returns the whole STREAM frame length, both header and payload included. This ensures that qcc_build_frms() won't return a nul value if new frames are encoded, even empty ones. This must be backported up to 3.1. --- src/mux_quic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mux_quic.c b/src/mux_quic.c index e3fa05cb48ec..29d950e81830 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -2014,7 +2014,7 @@ static void qcs_destroy(struct qcs *qcs) * truncated if greater than . This allows to prepare several * frames in a loop while respecting connection flow control window. * - * Returns the payload length of the STREAM frame or a negative error code. + * Returns the length of the STREAM frame or a negative error code. */ static int qcs_build_stream_frm(struct qcs *qcs, struct buffer *out, char fin, struct list *frm_list, uint64_t window_conn) @@ -2103,7 +2103,7 @@ static int qcs_build_stream_frm(struct qcs *qcs, struct buffer *out, char fin, qcc->conn, qcs, &arg); } - return total; + return qc_frm_len(frm); err: TRACE_LEAVE(QMUX_EV_QCS_SEND, qcc->conn, qcs); @@ -2265,7 +2265,7 @@ static int qcs_send_stop_sending(struct qcs *qcs) * This allows to prepare several frames in a loop while respecting connection * flow control window. * - * Returns the payload length of the STREAM frame or a negative error code. + * Returns the length of the STREAM frame or a negative error code. */ static int qcs_send(struct qcs *qcs, struct list *frms, uint64_t window_conn) {