mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge #20616: Check CJDNS address is valid
f7264fff0a098f8b6354c7373b8790791c25dd07 Check if Cjdns address is valid (Lucas Ontivero)
Pull request description:
CJDNS addresses start with 0xFC and for that reason if a netaddr was unserialized with network type cjdns but its address prefix is not 0xFC then that netaddr should be considered invalid.
ACKs for top commit:
jonatack:
ACK f7264fff0a098f8b6354c7373b8790791c25dd07
practicalswift:
cr ACK f7264fff0a098f8b6354c7373b8790791c25dd07: patch looks correct
theStack:
ACK f7264fff0a098f8b6354c7373b8790791c25dd07 ✔️
Tree-SHA512: 5300df2ffbbd69c40271b6d8df96cca98eb3e1ee76aba62c9c76025d083788ab1f1332775890c63b06e02ca593863a867cd53956bce5962383e8450487898669
This commit is contained in:
parent
9ff3643bfa
commit
5ff3dd1b34
@ -436,6 +436,11 @@ bool CNetAddr::IsValid() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CJDNS addresses always start with 0xfc
|
||||||
|
if (IsCJDNS() && (m_addr[0] != 0xFC)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// documentation IPv6 address
|
// documentation IPv6 address
|
||||||
if (IsRFC3849())
|
if (IsRFC3849())
|
||||||
return false;
|
return false;
|
||||||
|
@ -549,6 +549,16 @@ BOOST_AUTO_TEST_CASE(cnetaddr_unserialize_v2)
|
|||||||
BOOST_CHECK_EQUAL(addr.ToString(), "fc00:1:2:3:4:5:6:7");
|
BOOST_CHECK_EQUAL(addr.ToString(), "fc00:1:2:3:4:5:6:7");
|
||||||
BOOST_REQUIRE(s.empty());
|
BOOST_REQUIRE(s.empty());
|
||||||
|
|
||||||
|
// Invalid CJDNS, wrong prefix.
|
||||||
|
s << MakeSpan(ParseHex("06" // network type (CJDNS)
|
||||||
|
"10" // address length
|
||||||
|
"aa000001000200030004000500060007" // address
|
||||||
|
));
|
||||||
|
s >> addr;
|
||||||
|
BOOST_CHECK(addr.IsCJDNS());
|
||||||
|
BOOST_CHECK(!addr.IsValid());
|
||||||
|
BOOST_REQUIRE(s.empty());
|
||||||
|
|
||||||
// Invalid CJDNS, with bogus length.
|
// Invalid CJDNS, with bogus length.
|
||||||
s << MakeSpan(ParseHex("06" // network type (CJDNS)
|
s << MakeSpan(ParseHex("06" // network type (CJDNS)
|
||||||
"01" // address length
|
"01" // address length
|
||||||
|
Loading…
Reference in New Issue
Block a user