]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Zero initialise msghdr prior to calling sendmesg
authorArne Schwabe <arne@rfc2549.org>
Tue, 5 Jan 2021 13:17:58 +0000 (14:17 +0100)
committerGert Doering <gert@greenie.muc.de>
Mon, 18 Jan 2021 11:54:03 +0000 (12:54 +0100)
This ensure that all unused fields in msg are zero.

Spotted by Coverity:

Using uninitialized value "msg". Field "msg.msg_flags" is uninitialized
when calling "sendmsg".

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210105131758.20311-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21418.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit aa58035a955a2ae7ffa2b93ca2c8d2c6e5472695)

src/openvpn/manage.c

index 11d5aa7c13fee54e2af02d830754e45bd5265c9f..d86b6a79588a8a57bad8fd0a0a9cb1c3aa66357c 100644 (file)
@@ -2102,7 +2102,7 @@ man_io_error(struct management *man, const char *prefix)
 static ssize_t
 man_send_with_fd(int fd, void *ptr, size_t nbytes, int flags, int sendfd)
 {
-    struct msghdr msg;
+    struct msghdr msg = { 0 };
     struct iovec iov[1];
 
     union {
@@ -2134,7 +2134,7 @@ man_send_with_fd(int fd, void *ptr, size_t nbytes, int flags, int sendfd)
 static ssize_t
 man_recv_with_fd(int fd, void *ptr, size_t nbytes, int flags, int *recvfd)
 {
-    struct msghdr msghdr;
+    struct msghdr msghdr = { 0 };
     struct iovec iov[1];
     ssize_t n;