fuzz: Abort when global PRNG is used before SeedRand::ZEROS

This commit is contained in:
MarcoFalke
2024-12-20 16:15:32 +01:00
parent 433412fd84
commit fa3c787b62
3 changed files with 10 additions and 6 deletions

View File

@@ -79,7 +79,7 @@ void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target,
static std::string_view g_fuzz_target;
static const TypeTestOneInput* g_test_one_input{nullptr};
inline void test_one_input(FuzzBufferType buffer)
static void test_one_input(FuzzBufferType buffer)
{
CheckGlobals check{};
(*Assert(g_test_one_input))(buffer);
@@ -108,12 +108,12 @@ void ResetCoverageCounters() {}
#endif
void initialize()
static void initialize()
{
// By default, make the RNG deterministic with a fixed seed. This will affect all
// randomness during the fuzz test, except:
// - GetStrongRandBytes(), which is used for the creation of private key material.
// - Creating a BasicTestingSetup or derived class will switch to a random seed.
// - Randomness obtained before this call in g_rng_temp_path_init
SeedRandomStateForTest(SeedRand::ZEROS);
// Terminate immediately if a fuzzing harness ever tries to create a socket.