Module Name:    src
Committed By:   christos
Date:           Mon Dec  1 17:07:43 UTC 2014

Modified Files:
        src/sys/netinet: in.c

Log Message:
Don't pass junk in sin_family and sin_len for SIOCGIFNETMASK, and explain why.
XXX: pullup 7?


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/netinet/in.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/in.c
diff -u src/sys/netinet/in.c:1.148 src/sys/netinet/in.c:1.149
--- src/sys/netinet/in.c:1.148	Tue Sep  9 16:16:12 2014
+++ src/sys/netinet/in.c	Mon Dec  1 12:07:43 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: in.c,v 1.148 2014/09/09 20:16:12 rmind Exp $	*/
+/*	$NetBSD: in.c,v 1.149 2014/12/01 17:07:43 christos Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.148 2014/09/09 20:16:12 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.149 2014/12/01 17:07:43 christos Exp $");
 
 #include "opt_inet.h"
 #include "opt_inet_conf.h"
@@ -427,6 +427,7 @@ in_control(struct socket *so, u_long cmd
 			ia->ia_ifa.ifa_getifa = NULL;
 #endif /* IPSELSRC */
 			ia->ia_sockmask.sin_len = 8;
+			ia->ia_sockmask.sin_family = AF_INET;
 			if (ifp->if_flags & IFF_BROADCAST) {
 				ia->ia_broadaddr.sin_len = sizeof(ia->ia_addr);
 				ia->ia_broadaddr.sin_family = AF_INET;
@@ -473,7 +474,14 @@ in_control(struct socket *so, u_long cmd
 		break;
 
 	case SIOCGIFNETMASK:
-		ifreq_setaddr(cmd, ifr, sintocsa(&ia->ia_sockmask));
+		/* 
+		 * We keep the number of trailing zero bytes the sin_len field
+		 * of ia_sockmask, so we fix this before we pass it back to
+		 * userland.
+		 */
+		oldaddr = ia->ia_sockmask;
+		oldaddr.sin_len = sizeof(struct sockaddr_in);
+		ifreq_setaddr(cmd, ifr, (const void *)&oldaddr);
 		break;
 
 	case SIOCSIFDSTADDR:

Reply via email to