From 33333755f2edcbe88fcd136f6fef81f94819002e Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 6 Apr 2021 12:47:04 +0200 Subject: [PATCH] fuzz: Fix uninitialized read in test --- src/test/fuzz/util.cpp | 8 ++++++++ src/test/fuzz/util.h | 8 +++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/test/fuzz/util.cpp b/src/test/fuzz/util.cpp index d786ac1db11..cf5244e3148 100644 --- a/src/test/fuzz/util.cpp +++ b/src/test/fuzz/util.cpp @@ -7,6 +7,14 @@ #include #include +bool FuzzedSock::Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred ) const +{ + if (!m_fuzzed_data_provider.ConsumeBool()) { + return false; + } + if (occurred) *occurred = 0; + return true; +} void FillNode(FuzzedDataProvider& fuzzed_data_provider, CNode& node, bool init_version) noexcept { diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 50d3ac66e5f..adcdd717488 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -738,12 +738,10 @@ public: return 0; } - bool Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred = nullptr) const override - { - return m_fuzzed_data_provider.ConsumeBool(); - } + bool Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred = nullptr) const override; - bool IsConnected(std::string& errmsg) const override { + bool IsConnected(std::string& errmsg) const override + { if (m_fuzzed_data_provider.ConsumeBool()) { return true; }