From: Arne Schwabe Date: Tue, 5 Jan 2021 13:17:58 +0000 (+0100) Subject: Zero initialise msghdr prior to calling sendmesg X-Git-Tag: v2.5.1~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a65d39bfd27cf5612e55dd536dd189e1a62624c2;p=thirdparty%2Fopenvpn.git Zero initialise msghdr prior to calling sendmesg 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 Acked-by: Antonio Quartulli 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 (cherry picked from commit aa58035a955a2ae7ffa2b93ca2c8d2c6e5472695) --- diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index 11d5aa7c1..d86b6a795 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -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;