diff options
author | Jack Lloyd <[email protected]> | 2017-09-02 08:21:58 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-09-02 08:21:58 -0400 |
commit | 4d8d8594b7a75675a19b7feec8fd917b92ec0edd (patch) | |
tree | 525daf1ac9aaec38403b1ef864ff2942c16a6c57 /src/fuzzer/pkcs1.cpp | |
parent | bc7608874cf7ec4aef35a6e693dbbbf79c83b519 (diff) |
Clean up fuzzer code a bit
If we ever output something to the terminal it should be because
we are crashing.
Diffstat (limited to 'src/fuzzer/pkcs1.cpp')
-rw-r--r-- | src/fuzzer/pkcs1.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/fuzzer/pkcs1.cpp b/src/fuzzer/pkcs1.cpp index a0323d2b2..8a297ff7f 100644 --- a/src/fuzzer/pkcs1.cpp +++ b/src/fuzzer/pkcs1.cpp @@ -51,7 +51,7 @@ void fuzz(const uint8_t in[], size_t len) else if(valid_mask == 0xFF) lib_rejected = false; else - abort(); + FUZZER_WRITE_AND_CRASH("Invalid valid_mask from unpad"); } catch(Botan::Decoding_Error&) { lib_rejected = true; } @@ -61,22 +61,15 @@ void fuzz(const uint8_t in[], size_t len) } catch(Botan::Decoding_Error& e) { ref_rejected = true; } - if(lib_rejected == ref_rejected) - { - return; // ok, they agree - } - - // otherwise: incorrect result, log info and crash if(lib_rejected == true && ref_rejected == false) { - std::cerr << "Library rejected input accepted by ref\n"; - std::cerr << "Ref decoded " << Botan::hex_encode(ref_result) << "\n"; + FUZZER_WRITE_AND_CRASH("Library rejected input accepted by ref " + << Botan::hex_encode(ref_result)); } else if(ref_rejected == true && lib_rejected == false) { - std::cerr << "Library accepted input reject by ref\n"; - std::cerr << "Lib decoded " << Botan::hex_encode(lib_result) << "\n"; + FUZZER_WRITE_AND_CRASH("Library accepted input rejected by ref " + << Botan::hex_encode(lib_result)); } - - abort(); + // otherwise the two implementations agree } |