]> 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:52:30 +0000 (12:52 +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>
src/openvpn/manage.c

index 446b82f49b42cf609c160a7da85209bb65c639ef..ed9dde1ecd945537059f1816b420ab1f2e5cf51c 100644 (file)
@@ -2079,7 +2079,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 {
@@ -2111,7 +2111,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;