From fe7e798365c6e9dd1e199304e9028630af4b29a8 Mon Sep 17 00:00:00 2001 From: Jeremie Courreges-Anglas Date: Sun, 1 Dec 2019 21:12:43 +0000 Subject: Don't require a valid sa_len for a bunch of IPv4 "get" ioctls Same fix as for the IPv6 case. Fixes a regression in ports/net/openvpn spotted by landry@, ok bluhm@ --- sys/netinet/in.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sys/netinet/in.c') diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 149aa3564d6..85116527742 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.167 2019/11/28 00:50:41 bluhm Exp $ */ +/* $OpenBSD: in.c,v 1.168 2019/12/01 21:12:42 jca Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -557,11 +557,14 @@ in_ioctl_get(u_long cmd, caddr_t data, struct ifnet *ifp) struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa; struct in_ifaddr *ia = NULL; + struct sockaddr *sa; struct sockaddr_in *sin = NULL; int error = 0; - if (ifr->ifr_addr.sa_family == AF_INET) { - error = in_sa2sin(&ifr->ifr_addr, &sin); + sa = &ifr->ifr_addr; + if (sa->sa_family == AF_INET) { + sa->sa_len = sizeof(struct sockaddr_in); + error = in_sa2sin(sa, &sin); if (error) return (error); } -- cgit v1.2.3