diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-11-30 10:38:40 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-11-30 10:39:27 -0500 |
commit | d8bc0ce1da1c3f95ba927f3a1ef357c5e2ead02d (patch) | |
tree | 2e447104b02d7e42e7c3efeae19d197841d7696e /src/test | |
parent | 9f556622c57d3f7a0fdc8e3807fd798ee4b5a2fe (diff) | |
parent | f9db08e8ca6821147e12db772d15de106d8c8375 (diff) | |
download | bitcoin-d8bc0ce1da1c3f95ba927f3a1ef357c5e2ead02d.tar.xz |
Merge #14835: [0.17] Further Backports
f9db08e8ca qa: Avoid race in p2p_invalid_block by waiting for the block request (MarcoFalke)
79358817e5 Add SAFE_CHARS[SAFE_CHARS_URI]: Chars allowed in URIs (RFC 3986) (practicalswift)
9666dbaf09 rpc: Make HTTP RPC debug logging more informative (practicalswift)
b90157891a add test demonstrating addrLocal UB (Kaz Wesley)
6f04264bbb fix uninitialized read when stringifying an addrLocal (Kaz Wesley)
5782fdcd8c Throw error if CPubKey is invalid during PSBT keypath serialization (Gregory Sanders)
de5e48a461 Bugfix: RPC: Add address_type named param for createmultisig (Luke Dashjr)
df5131bd41 gui: explicitly disable "Dark Mode" appearance on macOS (fanquake)
Pull request description:
Backports #14593, #14596, #14618, #14690 and #14728 to the 0.17 branch.
Tree-SHA512: fcda4b75fcb71bb80cc8bde2a2b98ff5c0239dfa754ac980b1a91a90409502ac7678326399a4fc03a773074339dbf8b3d11750c91fe4302741a954745acfcca1
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/net_tests.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index 4c56938ec9..ae4841de5a 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -189,4 +189,42 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test) BOOST_CHECK(pnode2->fFeeler == false); } +// prior to PR #14728, this test triggers an undefined behavior +BOOST_AUTO_TEST_CASE(ipv4_peer_with_ipv6_addrMe_test) +{ + // set up local addresses; all that's necessary to reproduce the bug is + // that a normal IPv4 address is among the entries, but if this address is + // !IsRoutable the undefined behavior is easier to trigger deterministically + { + LOCK(cs_mapLocalHost); + in_addr ipv4AddrLocal; + ipv4AddrLocal.s_addr = 0x0100007f; + CNetAddr addr = CNetAddr(ipv4AddrLocal); + LocalServiceInfo lsi; + lsi.nScore = 23; + lsi.nPort = 42; + mapLocalHost[addr] = lsi; + } + + // create a peer with an IPv4 address + in_addr ipv4AddrPeer; + ipv4AddrPeer.s_addr = 0xa0b0c001; + CAddress addr = CAddress(CService(ipv4AddrPeer, 7777), NODE_NETWORK); + std::unique_ptr<CNode> pnode = MakeUnique<CNode>(0, NODE_NETWORK, 0, INVALID_SOCKET, addr, 0, 0, CAddress{}, std::string{}, false); + pnode->fSuccessfullyConnected.store(true); + + // the peer claims to be reaching us via IPv6 + in6_addr ipv6AddrLocal; + memset(ipv6AddrLocal.s6_addr, 0, 16); + ipv6AddrLocal.s6_addr[0] = 0xcc; + CAddress addrLocal = CAddress(CService(ipv6AddrLocal, 7777), NODE_NETWORK); + pnode->SetAddrLocal(addrLocal); + + // before patch, this causes undefined behavior detectable with clang's -fsanitize=memory + AdvertiseLocal(&*pnode); + + // suppress no-checks-run warning; if this test fails, it's by triggering a sanitizer + BOOST_CHECK(1); +} + BOOST_AUTO_TEST_SUITE_END() |