From 609e7e8d40c0dc8737e598799d6b70198992ecbf Mon Sep 17 00:00:00 2001 From: Hubert Chathi Date: Wed, 17 Nov 2021 14:18:03 -0500 Subject: [PATCH] make sure we have enough space for the encrypted and encoded version of the junk --- tests/test_group_session.cpp | 4 ++-- tests/test_olm.cpp | 4 ++-- tests/test_pk.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_group_session.cpp b/tests/test_group_session.cpp index 251971c..59b0a20 100644 --- a/tests/test_group_session.cpp +++ b/tests/test_group_session.cpp @@ -55,7 +55,7 @@ int main() { /* Deliberately corrupt the pickled session by supplying a junk suffix and * ensure this is caught as an error. */ const size_t junk_length = 1; - std::vector junk_pickle(pickle_length + junk_length); + std::vector junk_pickle(pickle_length + _olm_enc_output_length(junk_length)); olm_pickle_outbound_group_session( session, "secret_key", 10, junk_pickle.data(), pickle_length @@ -110,7 +110,7 @@ int main() { /* Deliberately corrupt the pickled session by supplying a junk suffix and * ensure this is caught as an error. */ const size_t junk_length = 1; - std::vector junk_pickle(pickle_length + junk_length); + std::vector junk_pickle(pickle_length + _olm_enc_output_length(junk_length)); olm_pickle_inbound_group_session( session, "secret_key", 10, junk_pickle.data(), pickle_length diff --git a/tests/test_olm.cpp b/tests/test_olm.cpp index 215b180..d95be79 100644 --- a/tests/test_olm.cpp +++ b/tests/test_olm.cpp @@ -71,7 +71,7 @@ assert_equals(pickle1.data(), pickle2.data(), pickle_length); /* Deliberately corrupt the pickled account by supplying a junk suffix and * ensure this is caught as an error. */ const size_t junk_length = 1; -std::vector junk_pickle(pickle_length + junk_length); +std::vector junk_pickle(pickle_length + _olm_enc_output_length(junk_length)); res = ::olm_pickle_account( account, "secret_key", 10, junk_pickle.data(), pickle_length); @@ -162,7 +162,7 @@ assert_equals(pickle1.data(), pickle2.data(), pickle_length); /* Deliberately corrupt the pickled session by supplying a junk suffix and * ensure this is caught as an error. */ const size_t junk_length = 1; -std::vector junk_pickle(pickle_length + junk_length); +std::vector junk_pickle(pickle_length + _olm_enc_output_length(junk_length)); res = ::olm_pickle_session( session, "secret_key", 10, junk_pickle.data(), pickle_length); diff --git a/tests/test_pk.cpp b/tests/test_pk.cpp index f975029..3b3cb48 100644 --- a/tests/test_pk.cpp +++ b/tests/test_pk.cpp @@ -146,7 +146,7 @@ assert_equals(alice_public, pubkey.data(), olm_pk_key_length()); * ensure this is caught as an error. */ const size_t junk_length = 1; std::size_t pickle_length = olm_pickle_pk_decryption_length(decryption); -std::vector junk_pickle(pickle_length + junk_length); +std::vector junk_pickle(pickle_length + _olm_enc_output_length(junk_length)); olm_pickle_pk_decryption( decryption,