From fa7a883f5a219d5f3c2f992b090db4e6c279db12 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 18 Aug 2021 09:57:56 +0200 Subject: addrman: Replace assert with throw on corrupt data Assert should only be used for program internal logic errors, not to sanitize external user input. --- src/addrman.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/addrman.cpp b/src/addrman.cpp index a6f38075d8..7c6b8fe64d 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -386,7 +386,12 @@ void CAddrMan::Unserialize(Stream& s_) LogPrint(BCLog::ADDRMAN, "addrman lost %i new and %i tried addresses due to collisions or invalid addresses\n", nLostUnk, nLost); } - Check(); + const int check_code{ForceCheckAddrman()}; + if (check_code != 0) { + throw std::ios_base::failure(strprintf( + "Corrupt data. Consistency check failed with code %s", + check_code)); + } } // explicit instantiation -- cgit v1.2.3