aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-08-18 09:57:56 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-09-21 10:09:45 +0200
commitfa7a883f5a219d5f3c2f992b090db4e6c279db12 (patch)
tree6b6660bc9fb7f0d00c2a13a30ff47204f7927144 /src
parentfa298971e6890715e2b0b93f2a7f445d32d6622f (diff)
addrman: Replace assert with throw on corrupt data
Assert should only be used for program internal logic errors, not to sanitize external user input.
Diffstat (limited to 'src')
-rw-r--r--src/addrman.cpp7
1 files changed, 6 insertions, 1 deletions
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