aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2022-02-10 18:02:05 +0100
committerMarcoFalke <falke.marco@gmail.com>2022-02-25 14:16:32 +0100
commitfa097d074bc1afcc2a52976796bb618f7c6a68b3 (patch)
tree568e246806387910200c45080ad7e2f75a3a7fa4 /src/addrman.cpp
parentee8c99712561bfbe823d9cd787a421b5424a75d9 (diff)
downloadbitcoin-fa097d074bc1afcc2a52976796bb618f7c6a68b3.tar.xz
addrman: Log too low compat value
Also remove uint8_t{} casts from values that are already of the same type.
Diffstat (limited to 'src/addrman.cpp')
-rw-r--r--src/addrman.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp
index f91a979934..2fd8143c1c 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -246,12 +246,18 @@ void AddrManImpl::Unserialize(Stream& s_)
uint8_t compat;
s >> compat;
+ if (compat < INCOMPATIBILITY_BASE) {
+ throw std::ios_base::failure(strprintf(
+ "Corrupted addrman database: The compat value (%u) "
+ "is lower than the expected minimum value %u.",
+ compat, INCOMPATIBILITY_BASE));
+ }
const uint8_t lowest_compatible = compat - INCOMPATIBILITY_BASE;
if (lowest_compatible > FILE_FORMAT) {
throw InvalidAddrManVersionError(strprintf(
"Unsupported format of addrman database: %u. It is compatible with formats >=%u, "
"but the maximum supported by this version of %s is %u.",
- uint8_t{format}, uint8_t{lowest_compatible}, PACKAGE_NAME, uint8_t{FILE_FORMAT}));
+ uint8_t{format}, lowest_compatible, PACKAGE_NAME, uint8_t{FILE_FORMAT}));
}
s >> nKey;