diff options
author | Jack Lloyd <[email protected]> | 2017-04-13 12:20:24 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-04-13 12:20:24 -0400 |
commit | cd72f4ac0bfc6ff5ecafb804e6c61c8d2902d6c4 (patch) | |
tree | d355f50bf7b038add3d05aeac015d92bb16429f9 /src/tests/test_asn1.cpp | |
parent | 5c79da3a4fd6ac45047834681c3efd8fba3c7825 (diff) |
Add test for OSS-Fuzz 813
Diffstat (limited to 'src/tests/test_asn1.cpp')
-rw-r--r-- | src/tests/test_asn1.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/tests/test_asn1.cpp b/src/tests/test_asn1.cpp new file mode 100644 index 000000000..3427d391d --- /dev/null +++ b/src/tests/test_asn1.cpp @@ -0,0 +1,67 @@ +/* +* (C) 2017 Jack Lloyd +* +* Botan is released under the Simplified BSD License (see license.txt) +*/ + +#include "tests.h" + +#if defined(BOTAN_HAS_ASN1) + #include <botan/der_enc.h> + #include <botan/ber_dec.h> +#endif + +namespace Botan_Tests { + +#if defined(BOTAN_HAS_ASN1) + +namespace { + +Test::Result test_ber_stack_recursion() + { + Test::Result result("BER stack recursion"); + + // OSS-Fuzz #813 GitHub #989 + + try + { + const std::vector<uint8_t> in(10000000, 0); + Botan::DataSource_Memory input(in.data(), in.size()); + Botan::BER_Decoder dec(input); + + while(dec.more_items()) + { + Botan::BER_Object obj; + dec.get_next(obj); + } + } + catch(Botan::Decoding_Error&) + { + } + + result.test_success("No crash"); + + return result; + } + +} + +class ASN1_Tests : public Test + { + public: + std::vector<Test::Result> run() override + { + std::vector<Test::Result> results; + + results.push_back(test_ber_stack_recursion()); + + return results; + } + }; + +BOTAN_REGISTER_TEST("asn1", ASN1_Tests); + +#endif + +} + |