From: Guus Sliepen Date: Tue, 26 Jun 2018 14:09:54 +0000 (+0200) Subject: Fix valgrind warnings about reading uninitialized bytes. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=13ef38b7a24efc84122b4d2bfc86cddbc359b94f;p=meshlink Fix valgrind warnings about reading uninitialized bytes. This is caused by memcpy()ing sockaddr_t structs that have only been partially written to. --- diff --git a/src/net_packet.c b/src/net_packet.c index 7db041b9..5596d603 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -555,7 +555,7 @@ void handle_incoming_vpn_data(event_loop_t *loop, void *data, int flags) { listen_socket_t *ls = data; vpn_packet_t pkt; char *hostname; - sockaddr_t from; + sockaddr_t from = {0}; socklen_t fromlen = sizeof(from); node_t *n; int len; diff --git a/src/net_socket.c b/src/net_socket.c index c03b17fb..68bf98f4 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -571,7 +571,7 @@ void handle_new_meta_connection(event_loop_t *loop, void *data, int flags) { meshlink_handle_t *mesh = loop->data; listen_socket_t *l = data; connection_t *c; - sockaddr_t sa; + sockaddr_t sa = {0}; int fd; socklen_t len = sizeof(sa); diff --git a/src/netutl.c b/src/netutl.c index d38b1a18..2a62c18a 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -52,7 +52,7 @@ struct addrinfo *str2addrinfo(const char *address, const char *service, int sock sockaddr_t str2sockaddr(const char *address, const char *port) { struct addrinfo *ai; - sockaddr_t result; + sockaddr_t result = {0}; int err; struct addrinfo hint = {