diff options
author | Hugo Landau <hlandau@openssl.org> | 2023-10-26 11:37:21 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2023-11-02 14:22:04 +0100 |
commit | 1d8a399f7bdbe9798cea9dc28bb6ee321f0f24f7 (patch) | |
tree | 9fe0de0b329a13e7affffe7f52c8ed96a0123661 | |
parent | 05937a70a14520a70e830af63aba4283ac6f3878 (diff) |
QUIC QTEST_FAULT: Allow deleted TLS extension to be output
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22523)
-rw-r--r-- | test/helpers/quictestlib.c | 21 | ||||
-rw-r--r-- | test/helpers/quictestlib.h | 6 | ||||
-rw-r--r-- | test/quicfaultstest.c | 2 |
3 files changed, 24 insertions, 5 deletions
diff --git a/test/helpers/quictestlib.c b/test/helpers/quictestlib.c index 26cd67e236..2c74b26252 100644 --- a/test/helpers/quictestlib.c +++ b/test/helpers/quictestlib.c @@ -929,12 +929,14 @@ int qtest_fault_resize_message(QTEST_FAULT *fault, size_t newlen) int qtest_fault_delete_extension(QTEST_FAULT *fault, unsigned int exttype, unsigned char *ext, - size_t *extlen) + size_t *extlen, + BUF_MEM *old_ext) { PACKET pkt, sub, subext; + WPACKET old_ext_wpkt; unsigned int type; const unsigned char *start, *end; - size_t newlen; + size_t newlen, w; size_t msglen = fault->handbuflen; if (!PACKET_buf_init(&pkt, ext, *extlen)) @@ -954,6 +956,21 @@ int qtest_fault_delete_extension(QTEST_FAULT *fault, /* Found it */ end = PACKET_data(&sub); + if (old_ext != NULL) { + if (!WPACKET_init(&old_ext_wpkt, old_ext)) + return 0; + + if (!WPACKET_memcpy(&old_ext_wpkt, PACKET_data(&subext), + PACKET_remaining(&subext)) + || !WPACKET_get_total_written(&old_ext_wpkt, &w)) { + WPACKET_cleanup(&old_ext_wpkt); + return 0; + } + + WPACKET_finish(&old_ext_wpkt); + old_ext->length = w; + } + /* * If we're not the last extension we need to move the rest earlier. The * cast below is safe because we own the underlying buffer and we're no diff --git a/test/helpers/quictestlib.h b/test/helpers/quictestlib.h index d1ac350c24..79de17d153 100644 --- a/test/helpers/quictestlib.h +++ b/test/helpers/quictestlib.h @@ -194,11 +194,13 @@ int qtest_fault_resize_message(QTEST_FAULT *fault, size_t newlen); * Helper function to delete an extension from an extension block. |exttype| is * the type of the extension to be deleted. |ext| points to the extension block. * On entry |*extlen| contains the length of the extension block. It is updated - * with the new length on exit. + * with the new length on exit. If old_ext is non-NULL, the deleted extension + * is appended to the given BUF_MEM. */ int qtest_fault_delete_extension(QTEST_FAULT *fault, unsigned int exttype, unsigned char *ext, - size_t *extlen); + size_t *extlen, + BUF_MEM *old_ext); /* * Add additional helper functions for querying extensions here (e.g. diff --git a/test/quicfaultstest.c b/test/quicfaultstest.c index 28f52cd6f2..ad200f7ace 100644 --- a/test/quicfaultstest.c +++ b/test/quicfaultstest.c @@ -168,7 +168,7 @@ static int drop_extensions_cb(QTEST_FAULT *fault, int *ext = (int *)encextcbarg; if (!qtest_fault_delete_extension(fault, *ext, ee->extensions, - &ee->extensionslen)) + &ee->extensionslen, NULL)) return 0; return 1; |