From: Amaury Denoyelle Date: Fri, 20 May 2022 13:14:57 +0000 (+0200) Subject: MINOR: mux-quic: close connection on error if different data at offset X-Git-Tag: v2.6-dev11~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc3d7166f45f3b27a1c01237e307bfbfe1dce7b5;p=thirdparty%2Fhaproxy.git 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 443eee7f06..77bb7aea4b 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -528,9 +528,19 @@ int qcc_recv(struct qcc *qcc, uint64_t id, uint64_t len, uint64_t offset, 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,