]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: close connection on error if different data at offset
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 20 May 2022 13:14:57 +0000 (15:14 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 20 May 2022 15:56:00 +0000 (17:56 +0200)
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.

src/mux_quic.c

index 443eee7f06ffb48bd6028582d68b27d90d301efc..77bb7aea4b1aa7c2fa6d71cf0d8bab3ad90611f0 100644 (file)
@@ -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,