mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Check if Cjdns address is valid
This commit is contained in:
parent
b76abae387
commit
f7264fff0a
2 changed files with 15 additions and 0 deletions
|
@ -437,6 +437,11 @@ bool CNetAddr::IsValid() const
|
|||
return false;
|
||||
}
|
||||
|
||||
// CJDNS addresses always start with 0xfc
|
||||
if (IsCJDNS() && (m_addr[0] != 0xFC)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// documentation IPv6 address
|
||||
if (IsRFC3849())
|
||||
return false;
|
||||
|
|
|
@ -604,6 +604,16 @@ BOOST_AUTO_TEST_CASE(cnetaddr_unserialize_v2)
|
|||
BOOST_CHECK_EQUAL(addr.ToString(), "fc00:1:2:3:4:5:6:7");
|
||||
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.
|
||||
s << MakeSpan(ParseHex("06" // network type (CJDNS)
|
||||
"01" // address length
|
||||
|
|
Loading…
Add table
Reference in a new issue