[CRIU] [PATCH 10/16] util-net: Zeroify structures

Cyrill Gorcunov gorcunov at openvz.org
Mon Feb 13 14:26:33 EST 2012


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 util-net.c |   36 +++++++++++++++++-------------------
 1 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/util-net.c b/util-net.c
index 0bc6490..4f826ca 100644
--- a/util-net.c
+++ b/util-net.c
@@ -5,21 +5,20 @@
 
 int send_fd(int sock, struct sockaddr_un *saddr, int len, int fd)
 {
-	struct msghdr hdr;
-	struct iovec data;
 	char cmsgbuf[CMSG_SPACE(sizeof(int))];
+	struct msghdr hdr = { };
+	struct iovec data = { };
 	struct cmsghdr* cmsg;
 	int *cmsg_data;
 	char dummy = '*';
 
-	data.iov_base = &dummy;
-	data.iov_len = sizeof(dummy);
+	data.iov_base	= &dummy;
+	data.iov_len	= sizeof(dummy);
 
-	hdr.msg_name = (struct sockaddr *)saddr;
-	hdr.msg_namelen = len;
-	hdr.msg_iov = &data;
-	hdr.msg_iovlen = 1;
-	hdr.msg_flags = 0;
+	hdr.msg_name	= (struct sockaddr *)saddr;
+	hdr.msg_namelen	= len;
+	hdr.msg_iov	= &data;
+	hdr.msg_iovlen	= 1;
 
 	hdr.msg_control = &cmsgbuf;
 	hdr.msg_controllen = CMSG_LEN(sizeof(int));
@@ -37,21 +36,20 @@ int send_fd(int sock, struct sockaddr_un *saddr, int len, int fd)
 
 int recv_fd(int sock)
 {
-	struct msghdr msg;
-	struct iovec iov;
-	char buf[1];
 	char ccmsg[CMSG_SPACE(sizeof(int))];
+	struct msghdr msg = { };
+	struct iovec iov = { };
 	struct cmsghdr *cmsg;
 	int *cmsg_data;
-	iov.iov_base = buf;
-	iov.iov_len = 1;
+	char buf[1];
 	int ret;
 
-	msg.msg_name = 0;
-	msg.msg_namelen = 0;
-	msg.msg_iov = &iov;
-	msg.msg_iovlen = 1;
-	msg.msg_control = ccmsg;
+	iov.iov_base	= buf;
+	iov.iov_len	= 1;
+
+	msg.msg_iov	= &iov;
+	msg.msg_iovlen	= 1;
+	msg.msg_control	= ccmsg;
 	msg.msg_controllen = sizeof(ccmsg);
 
 	ret = sys_recvmsg(sock, &msg, 0);
-- 
1.7.7.6



More information about the CRIU mailing list