QUIC CONFORMANCE: RFC 9000 s. 19.13: STREAM_DATA_BLOCKED Frames
authorHugo Landau <hlandau@openssl.org>
Tue, 6 Jun 2023 15:25:11 +0000 (16:25 +0100)
committerPauli <pauli@openssl.org>
Sun, 16 Jul 2023 22:17:57 +0000 (08:17 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21135)

ssl/quic/quic_rx_depack.c

index aa107455078bf5946733fef711b53d2729cacdb7..be4772e2f370e47a2f0003b21bfd7b1554ff22f2 100644 (file)
@@ -796,6 +796,23 @@ static int depack_do_frame_stream_data_blocked(PACKET *pkt,
                                           &stream))
         return 0; /* error already raised for us */
 
+    if (stream == NULL)
+        return 1; /* old deleted stream, not a protocol violation, ignore */
+
+    if (!ossl_quic_stream_has_recv(stream)) {
+        /*
+         * RFC 9000 s. 19.14: "An endpoint that receives a STREAM_DATA_BLOCKED
+         * frame for a send-only stream MUST terminate the connection with error
+         * STREAM_STATE_ERROR."
+         */
+        ossl_quic_channel_raise_protocol_error(ch,
+                                               QUIC_ERR_STREAM_STATE_ERROR,
+                                               OSSL_QUIC_FRAME_TYPE_STREAM_DATA_BLOCKED,
+                                               "STREAM_DATA_BLOCKED frame for "
+                                               "TX only stream");
+        return 0;
+    }
+
     /* No-op - informative/debugging frame. */
     return 1;
 }