Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet Don't pass junk in sin_family and sin_len for SI...
details: https://anonhg.NetBSD.org/src/rev/613495985cf6
branches: trunk
changeset: 334680:613495985cf6
user: christos <christos%NetBSD.org@localhost>
date: Mon Dec 01 17:07:43 2014 +0000
description:
Don't pass junk in sin_family and sin_len for SIOCGIFNETMASK, and explain why.
XXX: pullup 7?
diffstat:
sys/netinet/in.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diffs (42 lines):
diff -r 82d7f4e76776 -r 613495985cf6 sys/netinet/in.c
--- a/sys/netinet/in.c Mon Dec 01 08:39:43 2014 +0000
+++ b/sys/netinet/in.c Mon Dec 01 17:07:43 2014 +0000
@@ -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 @@
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 @@
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:
Home |
Main Index |
Thread Index |
Old Index