Skip to content

Commit b48a276

Browse files
fjahrhodlinator
andcommitted
fuzz: assert invalid addresses are not routable
Co-authored-by: Hodlinator <[email protected]>
1 parent e6c775c commit b48a276

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/test/fuzz/netaddress.cpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ FUZZ_TARGET(netaddress)
7272
(void)net_addr.IsRFC6598();
7373
(void)net_addr.IsRFC7343();
7474
(void)net_addr.IsRFC9637();
75-
if (!net_addr.IsRoutable()) {
75+
const bool routable{net_addr.IsRoutable()};
76+
if (!routable) {
7677
assert(net_addr.GetNetwork() == Network::NET_UNROUTABLE || net_addr.GetNetwork() == Network::NET_INTERNAL);
7778
}
7879
if (net_addr.IsTor()) {
@@ -84,7 +85,9 @@ FUZZ_TARGET(netaddress)
8485
if (net_addr.IsCJDNS()) {
8586
assert(net_addr.GetNetwork() == Network::NET_CJDNS);
8687
}
87-
(void)net_addr.IsValid();
88+
if (!net_addr.IsValid()) {
89+
assert(!routable);
90+
}
8891
(void)net_addr.ToStringAddr();
8992

9093
const CSubNet sub_net{net_addr, fuzzed_data_provider.ConsumeIntegral<uint8_t>()};

0 commit comments

Comments
 (0)