mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 20:54:23 +01:00
connectd: fix valgrind complaint on FreeBSD
As reported by Wladimir J. van der Laan. Valgrind will complain about padding and unset fields, so memset the structs. ``` ==42653== Syscall param socketcall.connect(serv_addr..sa_len) points to uninitialised byte(s) ==42653== at 0x4C7D19A: _connect (in /lib/libc.so.7) ==42653== by 0x4EE1F35: ??? (in /lib/libthr.so.3) ==42653== by 0x249D57: get_local_sockname (netaddress.c:212) ==42653== by 0x249CDB: guess_address (netaddress.c:242) ==42653== by 0x2473D0: public_address (connectd.c:1003) ==42653== by 0x246CE4: setup_listeners (connectd.c:0) ==42653== by 0x246566: connect_init (connectd.c:1311) ==42653== by 0x270CEB: next_plan (io.c:59) ==42653== by 0x2713EE: io_ready (io.c:417) ==42653== by 0x2726B1: io_loop (poll.c:445) ==42653== by 0x24618A: main (connectd.c:1703) ==42653== Address 0x7fc000690 is on thread 1's stack ==42653== in frame #3, created by guess_address (netaddress.c:231) ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
4507203a48
commit
089ecfe418
@@ -235,6 +235,7 @@ bool guess_address(struct wireaddr *addr)
|
||||
switch (addr->type) {
|
||||
case ADDR_TYPE_IPV4: {
|
||||
struct sockaddr_in sin;
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_port = htons(53);
|
||||
/* 8.8.8.8 */
|
||||
sin.sin_addr.s_addr = 0x08080808;
|
||||
@@ -246,6 +247,7 @@ bool guess_address(struct wireaddr *addr)
|
||||
}
|
||||
case ADDR_TYPE_IPV6: {
|
||||
struct sockaddr_in6 sin6;
|
||||
memset(&sin6, 0, sizeof(sin6));
|
||||
/* 2001:4860:4860::8888 */
|
||||
static const unsigned char pchGoogle[16]
|
||||
= {0x20,0x01,0x48,0x60,0x48,0x60,0,0,0,0,0,0,8,8,8,8};
|
||||
|
||||
Reference in New Issue
Block a user