MINOR: mux-quic: close connection on error if different data at offset
As specified by the RFC reception of different STREAM data for the same
offset should be treated with a CONNECTION_CLOSE with error
PROTOCOL_VIOLATION.
Use ncbuf API to detect this case : if add operation fails with
NCB_RET_DATA_REJ with add mode NCB_ADD_COMPARE.
diff --git a/src/mux_quic.c b/src/mux_quic.c
index 443eee7..77bb7ae 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -528,9 +528,19 @@
ret = ncb_add(&qcs->rx.ncbuf, offset - qcs->rx.offset, data, len, NCB_ADD_COMPARE);
if (ret != NCB_RET_OK) {
if (ret == NCB_RET_DATA_REJ) {
- /* TODO generate PROTOCOL_VIOLATION error */
+ /* RFC 9000 2.2. Sending and Receiving Data
+ *
+ * An endpoint could receive data for a stream at the
+ * same stream offset multiple times. Data that has
+ * already been received can be discarded. The data at
+ * a given offset MUST NOT change if it is sent
+ * multiple times; an endpoint MAY treat receipt of
+ * different data at the same offset within a stream as
+ * a connection error of type PROTOCOL_VIOLATION.
+ */
TRACE_DEVEL("leaving on data rejected", QMUX_EV_QCC_RECV|QMUX_EV_QCS_RECV,
qcc->conn, qcs);
+ qcc_emit_cc(qcc, QC_ERR_PROTOCOL_VIOLATION);
}
else if (ret == NCB_RET_GAP_SIZE) {
TRACE_DEVEL("cannot bufferize frame due to gap size limit", QMUX_EV_QCC_RECV|QMUX_EV_QCS_RECV,