Skip to contentSkip to conversation

Change in openvpn[master]: Fix various "Uninitialized scalar variable" warnings from Coverity

Openvpn-devel In review flichtenheld (Code Review) 3 participants 7 messages Jul 28, 2023 – Jan 17, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1690549401000.I45cd0917d24570ae9e9db7eb6c370756e4595842@...2715...

#1 lore raw

flichtenheld has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/318?usp=email )

Change subject: Fix various "Uninitialized scalar variable" warnings from Coverity
......................................................................

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

---
M src/openvpn/mudp.c
M src/openvpn/multi.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/socket.c

4 files changed, 7 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/18/318/1

src/openvpn/mudp.c +1 -1
index 81625ea..e6c99ae 100644
@@ -188,7 +188,7 @@
 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;
 
src/openvpn/multi.c +4 -4
index aad11b1..728a7b8 100644
@@ -1234,7 +1234,7 @@
                       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 @@
                      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;
@@ -3118,7 +3118,7 @@
 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();
 
@@ -3532,7 +3532,7 @@
     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;
 
src/openvpn/pkcs11_openssl.c +1 -1
index 40080ef..0ddabc7 100644
@@ -166,7 +166,7 @@
     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 */
src/openvpn/socket.c +1 -1
index 2d765cc..58231fb 100644
@@ -3301,7 +3301,7 @@
 {
     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 */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/318?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I45cd0917d24570ae9e9db7eb6c370756e4595842
Gerrit-Change-Number: 318
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/318?usp=email )

Change subject: Fix various "Uninitialized scalar variable" warnings from Coverity
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/318?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I45cd0917d24570ae9e9db7eb6c370756e4595842
Gerrit-Change-Number: 318
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sun, 08 Oct 2023 09:13:59 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 Fix various "Uninitialized scalar variable" warnings from Coverity

In reply to a message not in the archive

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

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/318
This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>

src/openvpn/mudp.c +1 -1
index 81625ea..e6c99ae 100644
@@ -188,7 +188,7 @@
 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;
 
src/openvpn/multi.c +4 -4
index aad11b1..728a7b8 100644
@@ -1234,7 +1234,7 @@
                       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 @@
                      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;
@@ -3118,7 +3118,7 @@
 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();
 
@@ -3532,7 +3532,7 @@
     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;
 
src/openvpn/pkcs11_openssl.c +1 -1
index 40080ef..0ddabc7 100644
@@ -166,7 +166,7 @@
     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 */
src/openvpn/socket.c +1 -1
index 2d765cc..58231fb 100644
@@ -3301,7 +3301,7 @@
 {
     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 */
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix various 'Uninitialized scalar variable' warnings from Coverity

Generally I'm not a big fan of code changes just to appease a checking tool, but I can see why coverity would warn (we pass on structures that contain possibly-uninitialized data, and the callee "might decide to use them").

Your patch has been applied to the master branch.

commit 327355f5174772ad2c788aaeb2a7b4db39cff385

Author: Frank Lichtenheld
Date:   Sun Oct 8 12:36:41 2023 +0200
     Fix various 'Uninitialized scalar variable' warnings from Coverity

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg27157.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

Hello plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/318?usp=email

to look at the new patch set (#2).

The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied now.

Change subject: Fix various "Uninitialized scalar variable" warnings from Coverity
......................................................................

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

---
M src/openvpn/mudp.c
M src/openvpn/multi.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/socket.c

4 files changed, 7 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/18/318/2

src/openvpn/mudp.c +1 -1
index 81625ea..e6c99ae 100644
@@ -188,7 +188,7 @@
 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;
 
src/openvpn/multi.c +4 -4
index f4f0b8a..4344126 100644
@@ -1234,7 +1234,7 @@
                       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 @@
                      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 @@
 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 @@
     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;
 
src/openvpn/pkcs11_openssl.c +1 -1
index aa0819f..1824c6b 100644
@@ -166,7 +166,7 @@
     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 */
src/openvpn/socket.c +1 -1
index 903f98b..480f4e5 100644
@@ -3298,7 +3298,7 @@
 {
     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 */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/318?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I45cd0917d24570ae9e9db7eb6c370756e4595842
Gerrit-Change-Number: 318
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#6 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: Fix various 'Uninitialized scalar variable' warnings from Coverity

In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/318?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by plaisthos

Change subject: Fix various 'Uninitialized scalar variable' warnings from Coverity
......................................................................

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

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27157.html

---
M src/openvpn/mudp.c
M src/openvpn/multi.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/socket.c

4 files changed, 7 insertions(+), 7 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/18/318/3

src/openvpn/mudp.c +1 -1
index 81625ea..e6c99ae 100644
@@ -188,7 +188,7 @@
 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;
 
src/openvpn/multi.c +4 -4
index f4f0b8a..4344126 100644
@@ -1234,7 +1234,7 @@
                       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 @@
                      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 @@
 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 @@
     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;
 
src/openvpn/pkcs11_openssl.c +1 -1
index aa0819f..1824c6b 100644
@@ -166,7 +166,7 @@
     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 */
src/openvpn/socket.c +1 -1
index 903f98b..480f4e5 100644
@@ -3298,7 +3298,7 @@
 {
     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 */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/318?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I45cd0917d24570ae9e9db7eb6c370756e4595842
Gerrit-Change-Number: 318
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#7 lore raw

[Openvpn-devel] [S] Change in openvpn[master]: Fix various 'Uninitialized scalar variable' warnings from Coverity

In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/318?usp=email )

Change subject: Fix various 'Uninitialized scalar variable' warnings from Coverity
......................................................................

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

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27157.html

---
M src/openvpn/mudp.c
M src/openvpn/multi.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/socket.c

4 files changed, 7 insertions(+), 7 deletions(-)
src/openvpn/mudp.c +1 -1
index 81625ea..e6c99ae 100644
@@ -188,7 +188,7 @@
 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;
 
src/openvpn/multi.c +4 -4
index f4f0b8a..4344126 100644
@@ -1234,7 +1234,7 @@
                       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 @@
                      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 @@
 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 @@
     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;
 
src/openvpn/pkcs11_openssl.c +1 -1
index aa0819f..1824c6b 100644
@@ -166,7 +166,7 @@
     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 */
src/openvpn/socket.c +1 -1
index 903f98b..480f4e5 100644
@@ -3298,7 +3298,7 @@
 {
     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 */

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/318?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I45cd0917d24570ae9e9db7eb6c370756e4595842
Gerrit-Change-Number: 318
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged