Commit 9a9c13b5f7 for openssl.org
commit 9a9c13b5f79196b457f2cdf253f0d3e5d3ae330d
Author: Andrew Dinh <andrewd@openssl.org>
Date: Thu Jul 30 10:05:37 2026 +0700
Port script_39
Assisted-by: Claude:claude-sonnet-5
Reviewed-by: Saša NedvÄ›dický <sashan@openssl.org>
Reviewed-by: Bob Beck <beck@openssl.org>
MergeDate: Wed Aug 12 02:11:03 2026
(Merged from https://github.com/openssl/openssl/pull/32138)
diff --git a/test/quic_multistream_test.c b/test/quic_multistream_test.c
index bfce417f3d..eae033b52d 100644
--- a/test/quic_multistream_test.c
+++ b/test/quic_multistream_test.c
@@ -2494,21 +2494,7 @@ err:
}
static const struct script_op script_39[] = {
- OP_S_SET_INJECT_PLAIN(script_39_inject_plain),
- OP_C_SET_ALPN("ossltest"),
- OP_C_CONNECT_WAIT(),
- OP_C_SET_DEFAULT_STREAM_MODE(SSL_DEFAULT_STREAM_MODE_NONE),
-
- OP_C_NEW_STREAM_BIDI(a, C_BIDI_ID(0)),
- OP_C_WRITE(a, "apple", 5),
- OP_S_BIND_STREAM_ID(a, C_BIDI_ID(0)),
- OP_S_READ_EXPECT(a, "apple", 5),
-
- OP_SET_INJECT_WORD(0, 1),
- OP_S_WRITE(a, "orange", 5),
-
- OP_C_EXPECT_CONN_CLOSE_INFO(OSSL_QUIC_ERR_FRAME_ENCODING_ERROR, 0, 0),
-
+ /* test moved to test/radix/quic_tests.c */
OP_END
};
diff --git a/test/radix/quic_ops.c b/test/radix/quic_ops.c
index 25bcd797bf..ce2b9db89c 100644
--- a/test/radix/quic_ops.c
+++ b/test/radix/quic_ops.c
@@ -1309,6 +1309,7 @@ struct radix_fault_st {
OSSL_QTX_IOVEC io;
size_t buf_alloc;
radix_fault_plain_cb cb;
+ QUIC_CHANNEL *ch;
uint64_t word0, word1;
};
@@ -1444,6 +1445,7 @@ DEF_FUNC(hf_set_inject_plain)
OPENSSL_free((unsigned char *)radix_fault.io.buf);
memset(&radix_fault, 0, sizeof(radix_fault));
radix_fault.cb = radix_fault_ptr_to_plain_cb(cbptr);
+ radix_fault.ch = ch;
if (!TEST_true(ossl_quic_channel_set_mutator(ch, radix_fault_mutate,
radix_fault_finish, &radix_fault)))
diff --git a/test/radix/quic_tests.c b/test/radix/quic_tests.c
index dd307a561b..308cf6c747 100644
--- a/test/radix/quic_tests.c
+++ b/test/radix/quic_tests.c
@@ -2424,8 +2424,108 @@ DEF_SCRIPT(script_38, "Fault injection - STREAM_DATA_BLOCKED for non-existent st
OP_EXPECT_CONN_CLOSE_INFO(C, OSSL_QUIC_ERR_STREAM_STATE_ERROR, 0, 0);
}
-DEF_SCRIPT(script_39, "place holder for multistrem script_39")
+/* 39. Fault injection - NEW_CONN_ID with zero-len CID */
+static int inject_new_conn_id_plain(RADIX_FAULT *fault, QUIC_PKT_HDR *hdr,
+ unsigned char *buf, size_t len)
+{
+ int ok = 0;
+ WPACKET wpkt;
+ unsigned char frame_buf[64];
+ size_t i, written;
+ uint64_t seq_no = 0, retire_prior_to = 0;
+ QUIC_CONN_ID new_cid = { 0 };
+
+ if (hdr->type != QUIC_PKT_TYPE_1RTT)
+ return 1;
+
+ switch (fault->word1) {
+ case 0:
+ return 1;
+ case 1:
+ new_cid.id_len = 0;
+ break;
+ case 2:
+ new_cid.id_len = 21;
+ break;
+ case 3:
+ new_cid.id_len = 1;
+ new_cid.id[0] = 0x55;
+
+ seq_no = 0;
+ retire_prior_to = 1;
+ break;
+ case 4:
+ /* Use our actual CID so we don't break connectivity. */
+ ossl_quic_channel_get_diag_local_cid(fault->ch, &new_cid);
+
+ seq_no = 2;
+ retire_prior_to = 2;
+ break;
+ case 5:
+ /*
+ * Use a bogus CID which will need to be ignored if connectivity is to
+ * be continued.
+ */
+ new_cid.id_len = 8;
+ new_cid.id[0] = 0x55;
+
+ seq_no = 1;
+ retire_prior_to = 1;
+ break;
+ }
+
+ if (!TEST_true(WPACKET_init_static_len(&wpkt, frame_buf,
+ sizeof(frame_buf), 0)))
+ return 0;
+
+ if (!TEST_true(WPACKET_quic_write_vlint(&wpkt, OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID))
+ || !TEST_true(WPACKET_quic_write_vlint(&wpkt, seq_no)) /* seq no */
+ || !TEST_true(WPACKET_quic_write_vlint(&wpkt, retire_prior_to)) /* retire prior to */
+ || !TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id_len))) /* len */
+ goto err;
+
+ for (i = 0; i < new_cid.id_len && i < OSSL_NELEM(new_cid.id); ++i)
+ if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, new_cid.id[i])))
+ goto err;
+
+ for (; i < new_cid.id_len; ++i)
+ if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x55)))
+ goto err;
+
+ for (i = 0; i < QUIC_STATELESS_RESET_TOKEN_LEN; ++i)
+ if (!TEST_true(WPACKET_put_bytes_u8(&wpkt, 0x42)))
+ goto err;
+
+ if (!TEST_true(WPACKET_get_total_written(&wpkt, &written))
+ || !radix_fault_prepend_frame(fault, frame_buf, written))
+ goto err;
+
+ ok = 1;
+err:
+ if (ok)
+ WPACKET_finish(&wpkt);
+ else
+ WPACKET_cleanup(&wpkt);
+ return ok;
+}
+
+DEF_SCRIPT(script_39, "Fault injection - NEW_CONN_ID with zero-len CID")
{
+ OP_SIMPLE_PAIR_CONN_ND();
+ OP_ACCEPT_CONN_WAIT_ND(L, S, 0);
+
+ OP_SET_INJECT_PLAIN(S, inject_new_conn_id_plain);
+
+ OP_NEW_STREAM(C, Ca, 0 /* bidirectional */);
+ OP_WRITE(Ca, "apple", 5);
+
+ OP_ACCEPT_STREAM_WAIT(S, Sa, 0);
+ OP_READ_EXPECT(Sa, "apple", 5);
+
+ OP_SET_INJECT_WORD(0, 1);
+ OP_WRITE(Sa, "orange", 5);
+
+ OP_EXPECT_CONN_CLOSE_INFO(C, OSSL_QUIC_ERR_FRAME_ENCODING_ERROR, 0, 0);
}
DEF_SCRIPT(script_40, "place holder for multistrem script_40")