Skip to content

Commit bfdf4ef

Browse files
committed
[asmap] Remove SanityCheckASMap() from netaddress
SanityCheckASMap(asmap, bits) simply calls through to SanityCheckASMap(asmap) in util/asmap. Update all callers to simply call that function.
1 parent 07a9ecc commit bfdf4ef

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

src/addrman.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <logging.h>
1010
#include <netaddress.h>
1111
#include <serialize.h>
12+
#include <util/asmap.h>
1213

1314
#include <cmath>
1415
#include <optional>
@@ -1028,7 +1029,7 @@ std::vector<bool> CAddrMan::DecodeAsmap(fs::path path)
10281029
bits.push_back((cur_byte >> bit) & 1);
10291030
}
10301031
}
1031-
if (!SanityCheckASMap(bits)) {
1032+
if (!SanityCheckASMap(bits, 128)) {
10321033
LogPrintf("Sanity check of asmap file %s failed\n", path);
10331034
return {};
10341035
}

src/netaddress.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,3 @@ bool operator<(const CSubNet& a, const CSubNet& b)
12421242
{
12431243
return (a.network < b.network || (a.network == b.network && memcmp(a.netmask, b.netmask, 16) < 0));
12441244
}
1245-
1246-
bool SanityCheckASMap(const std::vector<bool>& asmap)
1247-
{
1248-
return SanityCheckASMap(asmap, 128); // For IP address lookups, the input is 128 bits
1249-
}

src/netaddress.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,4 @@ class CService : public CNetAddr
567567
}
568568
};
569569

570-
bool SanityCheckASMap(const std::vector<bool>& asmap);
571-
572570
#endif // BITCOIN_NETADDRESS_H

src/test/fuzz/addrman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class CAddrManDeterministic : public CAddrMan
221221
[[nodiscard]] inline std::vector<bool> ConsumeAsmap(FuzzedDataProvider& fuzzed_data_provider) noexcept
222222
{
223223
std::vector<bool> asmap = ConsumeRandomLengthBitVector(fuzzed_data_provider);
224-
if (!SanityCheckASMap(asmap)) asmap.clear();
224+
if (!SanityCheckASMap(asmap, 128)) asmap.clear();
225225
return asmap;
226226
}
227227

src/test/fuzz/asmap.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <netaddress.h>
66
#include <test/fuzz/fuzz.h>
7+
#include <util/asmap.h>
78

89
#include <cstdint>
910
#include <vector>
@@ -42,7 +43,7 @@ FUZZ_TARGET(asmap)
4243
asmap.push_back((buffer[1 + i] >> j) & 1);
4344
}
4445
}
45-
if (!SanityCheckASMap(asmap)) return;
46+
if (!SanityCheckASMap(asmap, 128)) return;
4647

4748
const uint8_t* addr_data = buffer.data() + 1 + asmap_size;
4849
CNetAddr net_addr;

src/test/fuzz/net.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <test/fuzz/util.h>
1515
#include <test/util/net.h>
1616
#include <test/util/setup_common.h>
17+
#include <util/asmap.h>
1718

1819
#include <cstdint>
1920
#include <optional>
@@ -39,7 +40,7 @@ FUZZ_TARGET_INIT(net, initialize_net)
3940
},
4041
[&] {
4142
const std::vector<bool> asmap = ConsumeRandomLengthBitVector(fuzzed_data_provider);
42-
if (!SanityCheckASMap(asmap)) {
43+
if (!SanityCheckASMap(asmap, 128)) {
4344
return;
4445
}
4546
CNodeStats stats;

0 commit comments

Comments
 (0)