From b7b36decaf878a8c1dcfdb4a27196c730043474b Mon Sep 17 00:00:00 2001 From: Kaz Wesley Date: Wed, 14 Nov 2018 11:53:27 -0800 Subject: fix uninitialized read when stringifying an addrLocal Reachable from either place where SetIP is used when our best-guess addrLocal for a peer is IPv4, but the peer tells us it's reaching us at an IPv6 address. In that case, SetIP turns an IPv4 address into an IPv6 address without setting the scopeId, which is subsequently read in GetSockAddr during CNetAddr::ToStringIP and passed to getnameinfo. Fix by ensuring every constructor initializes the scopeId field with something. --- src/netaddress.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/netaddress.h') diff --git a/src/netaddress.h b/src/netaddress.h index cc0e4d4f12..dc55d8b1a8 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -33,7 +33,7 @@ class CNetAddr { protected: unsigned char ip[16]; // in network byte order - uint32_t scopeId; // for scoped/link-local ipv6 addresses + uint32_t scopeId{0}; // for scoped/link-local ipv6 addresses public: CNetAddr(); -- cgit v1.2.3