Don't pass junk in sin_family and sin_len for SIOCGIFNETMASK, and explain why.
XXX: pullup 7?
This commit is contained in:
parent
2e6c8dd691
commit
da48f144c9
@ -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, void *data, struct ifnet *ifp)
|
||||
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, void *data, struct ifnet *ifp)
|
||||
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user