From fede676aec9201cfd18b47ffb60ebb55fa90abac Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 21 Jul 2020 15:54:32 +0200 Subject: [PATCH 2/6] Make test more robust. Previously, a single character "0" was written to the RSA signature data to invalidate the signature. However, there is a 1 in 256 chance of there being a "0" character there, in which case the invalidation fails. Instead, overwrite nine characters, reducing the chance of failure to 1 in 2^72. --- src/tests/key-unlock.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/key-unlock.cpp b/src/tests/key-unlock.cpp index 66a44f0d..5610f065 100644 --- a/src/tests/key-unlock.cpp +++ b/src/tests/key-unlock.cpp @@ -149,8 +149,8 @@ TEST_F(rnp_tests, test_key_unlock_pgp) std::fstream verf("dummyfile.dat.pgp", std::ios_base::binary | std::ios_base::out | std::ios_base::in); off_t versize = file_size("dummyfile.dat.pgp"); - verf.seekg(versize - 3, std::ios::beg); - verf.write("0x0C", 1); + verf.seekg(versize - 9, std::ios::beg); + verf.write("foobarbaz", 9); verf.close(); assert_false(cli_rnp_process_file(&cfg, &rnp)); rnp_cfg_free(&cfg); -- 2.20.1