diff options
author | Matt Caswell <matt@openssl.org> | 2022-07-25 12:39:52 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2022-08-01 08:08:00 +0100 |
commit | 4000827fdbf3f6d70949186fdd2bc57638500885 (patch) | |
tree | 7595988d817633c5ccb2def52726d9863514321b /test/helpers | |
parent | 6d6b295ac39fcb0461f25fda69983d2dbb75f8f1 (diff) | |
download | openssl-new-4000827fdbf3f6d70949186fdd2bc57638500885.tar.gz |
Test that swapping the first app data record with Finished msg works
If the first app data record arrives before the Finished message we should
be able to buffer it and move on to the Finished message.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18868)
Diffstat (limited to 'test/helpers')
-rw-r--r-- | test/helpers/ssltestlib.c | 33 | ||||
-rw-r--r-- | test/helpers/ssltestlib.h | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/test/helpers/ssltestlib.c b/test/helpers/ssltestlib.c index f4f5b5049d..2c33851167 100644 --- a/test/helpers/ssltestlib.c +++ b/test/helpers/ssltestlib.c @@ -493,6 +493,39 @@ int mempacket_swap_epoch(BIO *bio) return 0; } +/* Take the last and penultimate packets and swap them around */ +int mempacket_swap_recent(BIO *bio) +{ + MEMPACKET_TEST_CTX *ctx = BIO_get_data(bio); + MEMPACKET *thispkt; + int numpkts = sk_MEMPACKET_num(ctx->pkts); + + /* We need at least 2 packets to be able to swap them */ + if (numpkts <= 1) + return 0; + + /* Get the penultimate packet */ + thispkt = sk_MEMPACKET_value(ctx->pkts, numpkts - 2); + if (thispkt == NULL) + return 0; + + if (sk_MEMPACKET_delete(ctx->pkts, numpkts - 2) != thispkt) + return 0; + + /* Re-add it to the end of the list */ + thispkt->num++; + if (sk_MEMPACKET_insert(ctx->pkts, thispkt, numpkts - 1) <= 0) + return 0; + + /* We also have to adjust the packet number of the other packet */ + thispkt = sk_MEMPACKET_value(ctx->pkts, numpkts - 2); + if (thispkt == NULL) + return 0; + thispkt->num--; + + return 1; +} + int mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum, int type) { diff --git a/test/helpers/ssltestlib.h b/test/helpers/ssltestlib.h index ee144e2f25..6f39388fca 100644 --- a/test/helpers/ssltestlib.h +++ b/test/helpers/ssltestlib.h @@ -50,6 +50,7 @@ void bio_s_always_retry_free(void); #define MEMPACKET_CTRL_SET_DUPLICATE_REC (4 << 15) int mempacket_swap_epoch(BIO *bio); +int mempacket_swap_recent(BIO *bio); int mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum, int type); |