]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
QUIC MULTISTREAM TEST: Ensure frames are only injected into correct packet types
authorHugo Landau <hlandau@openssl.org>
Tue, 31 Oct 2023 16:11:43 +0000 (16:11 +0000)
committerHugo Landau <hlandau@openssl.org>
Thu, 2 Nov 2023 08:11:31 +0000 (08:11 +0000)
Although the previous commit is enough to fix the immediate cause of the
stochastic failure on Windows, this is a more resilient fix; make sure
we only inject a given frame into the correct packet type for our
various injection functions.

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/22578)

test/quic_multistream_test.c

index 795a8973a150de32cc519cf53a9142140934e74c..8d513d7f08031bb035a1bcb16ce98561abab3b18 100644 (file)
@@ -2832,7 +2832,7 @@ static int script_23_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     unsigned char frame_buf[16];
     size_t written;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
@@ -2885,7 +2885,7 @@ static int script_24_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     unsigned char frame_buf[16];
     size_t written;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
@@ -2995,7 +2995,7 @@ static int script_28_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     unsigned char frame_buf[32];
     size_t written;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
@@ -3130,6 +3130,9 @@ static int script_32_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     size_t written;
     uint64_t type = OSSL_QUIC_FRAME_TYPE_STREAM_OFF_LEN, offset, flen, i;
 
+    if (hdr->type != QUIC_PKT_TYPE_1RTT)
+        return 1;
+
     switch (h->inject_word1) {
     default:
         return 0;
@@ -3344,6 +3347,9 @@ static int script_39_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     QUIC_CONN_ID new_cid = {0};
     QUIC_CHANNEL *ch = ossl_quic_tserver_get_channel(h->s_priv);
 
+    if (hdr->type != QUIC_PKT_TYPE_1RTT)
+        return 1;
+
     switch (h->inject_word1) {
     case 0:
         return 1;
@@ -3487,7 +3493,7 @@ static int script_41_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     unsigned char frame_buf[16];
     size_t written;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
@@ -3681,7 +3687,7 @@ static int script_44_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     unsigned char frame_buf[16];
     size_t written;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
@@ -3993,7 +3999,7 @@ static int script_52_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     WPACKET wpkt;
     uint64_t type = h->inject_word1;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     --h->inject_word0;
@@ -4082,7 +4088,7 @@ static int script_53_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     unsigned char *frame_buf = NULL;
     size_t frame_len, i;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     h->inject_word0 = 0;
@@ -4254,7 +4260,7 @@ static int script_58_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     size_t written;
     WPACKET wpkt;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
@@ -4377,7 +4383,7 @@ static int script_61_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     unsigned char frame_buf[32];
     size_t written;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
@@ -4557,7 +4563,7 @@ static int script_66_inject_plain(struct helper *h, QUIC_PKT_HDR *hdr,
     unsigned char frame_buf[64];
     size_t written;
 
-    if (h->inject_word0 == 0)
+    if (h->inject_word0 == 0 || hdr->type != QUIC_PKT_TYPE_1RTT)
         return 1;
 
     if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,