From 327355f5174772ad2c788aaeb2a7b4db39cff385 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sun, 8 Oct 2023 12:36:41 +0200 Subject: [PATCH] Fix various 'Uninitialized scalar variable' warnings from Coverity These are all not actually problems, since the uninitialized parts are either .unused members of the struct (mroute_addr) or only written to (buflen), but still doesn't hurt to explicitely initialize them. Change-Id: I45cd0917d24570ae9e9db7eb6c370756e4595842 Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Message-Id: <20231008103641.19864-1-frank@lichtenheld.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27157.html Signed-off-by: Gert Doering --- src/openvpn/mudp.c | 2 +- src/openvpn/multi.c | 8 ++++---- src/openvpn/pkcs11_openssl.c | 2 +- src/openvpn/socket.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 81625ea5a09..e6c99ae567e 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -188,7 +188,7 @@ struct multi_instance * multi_get_create_instance_udp(struct multi_context *m, bool *floated) { struct gc_arena gc = gc_new(); - struct mroute_addr real; + struct mroute_addr real = {0}; struct multi_instance *mi = NULL; struct hash *hash = m->hash; diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index f4f0b8a537c..43441268603 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -1234,7 +1234,7 @@ multi_learn_in_addr_t(struct multi_context *m, bool primary) { struct openvpn_sockaddr remote_si; - struct mroute_addr addr; + struct mroute_addr addr = {0}; CLEAR(remote_si); remote_si.addr.in4.sin_family = AF_INET; @@ -1273,7 +1273,7 @@ multi_learn_in6_addr(struct multi_context *m, int netbits, /* -1 if host route, otherwise # of network bits in address */ bool primary) { - struct mroute_addr addr; + struct mroute_addr addr = {0}; addr.len = 16; addr.type = MR_ADDR_IPV6; @@ -3137,7 +3137,7 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const uns void multi_process_float(struct multi_context *m, struct multi_instance *mi) { - struct mroute_addr real; + struct mroute_addr real = {0}; struct hash *hash = m->hash; struct gc_arena gc = gc_new(); @@ -3551,7 +3551,7 @@ multi_process_incoming_tun(struct multi_context *m, const unsigned int mpp_flags if (BLEN(&m->top.c2.buf) > 0) { unsigned int mroute_flags; - struct mroute_addr src, dest; + struct mroute_addr src = {0}, dest = {0}; const int dev_type = TUNNEL_TYPE(m->top.c1.tuntap); int16_t vid = 0; diff --git a/src/openvpn/pkcs11_openssl.c b/src/openvpn/pkcs11_openssl.c index aa0819f9aa6..1824c6bb122 100644 --- a/src/openvpn/pkcs11_openssl.c +++ b/src/openvpn/pkcs11_openssl.c @@ -166,7 +166,7 @@ xkey_pkcs11h_sign(void *handle, unsigned char *sig, CK_RSA_PKCS_PSS_PARAMS pss_params = {0}; unsigned char buf[EVP_MAX_MD_SIZE]; - size_t buflen; + size_t buflen = 0; size_t siglen_max = *siglen; unsigned char enc[EVP_MAX_MD_SIZE + 32]; /* 32 bytes enough for DigestInfo header */ diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 903f98b05d1..480f4e51c7e 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -3298,7 +3298,7 @@ link_socket_read_udp_posix_recvmsg(struct link_socket *sock, { struct iovec iov; uint8_t pktinfo_buf[PKTINFO_BUF_SIZE]; - struct msghdr mesg; + struct msghdr mesg = {0}; socklen_t fromlen = sizeof(from->dest.addr); ASSERT(sock->sd >= 0); /* can't happen */