From d69d8f904c9c558c7a9455ee816e494690d80ca8 Mon Sep 17 00:00:00 2001 From: Kurt Roeckx Date: Fri, 2 Dec 2016 19:34:54 +0100 Subject: Make the fuzzers more reproducible We want to be in the same global state each time we come in FuzzerTestOneInput(). There are various reasons why we might not be that include: - Initialization that happens on first use. This is mostly the RUN_ONCE() things, or loading of error strings. - Results that get cached. For instance a stack that is sorted, RSA blinding that has been set up, ... So I try to trigger as much as possible in FuzzerInitialize(), and for things I didn't find out how to trigger this it needs to happen in FuzzerTestOneInput(). Reviewed-by: Rich Salz GH: #2023 --- fuzz/bndiv.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'fuzz/bndiv.c') diff --git a/fuzz/bndiv.c b/fuzz/bndiv.c index dd6d9cfafe..30d84482a6 100644 --- a/fuzz/bndiv.c +++ b/fuzz/bndiv.c @@ -15,6 +15,7 @@ #include #include +#include #include "fuzzer.h" static BN_CTX *ctx; @@ -33,6 +34,9 @@ int FuzzerInitialize(int *argc, char ***argv) b5 = BN_new(); ctx = BN_CTX_new(); + OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL); + ERR_get_state(); + return 1; } @@ -104,6 +108,7 @@ int FuzzerTestOneInput(const uint8_t *buf, size_t len) done: OPENSSL_assert(success); + ERR_clear_error(); return 0; } -- cgit v1.2.3