summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2015-02-10 01:36:59 +0000
committerclaudio <claudio@openbsd.org>2015-02-10 01:36:59 +0000
commit6f06ee47f1819f0ca95799f928d0b5d1fa748ad1 (patch)
treed12f28a566cd8fbb5abed459e5433030f64f7ed8
parentchroot... (diff)
downloadwireguard-openbsd-6f06ee47f1819f0ca95799f928d0b5d1fa748ad1.tar.xz
wireguard-openbsd-6f06ee47f1819f0ca95799f928d0b5d1fa748ad1.zip
Nuke sin_zero before passing it on down into the ifa_ifwithaddr() that
way garbage in the pad bytes does not perturb the outcome. This fixes regress/sys/kern/bind. OK mpi@, phessler@, reyk@
-rw-r--r--sys/netinet/in_pcb.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 3f7c7a70c5b..8fc617850ce 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.166 2015/01/24 00:29:06 deraadt Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.167 2015/02/10 01:36:59 claudio Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -322,6 +322,9 @@ in_pcbbind(struct inpcb *inp, struct mbuf *nam, struct proc *p)
reuseport = SO_REUSEADDR|SO_REUSEPORT;
} else if (sin->sin_addr.s_addr != INADDR_ANY) {
sin->sin_port = 0; /* yech... */
+ /* ... must also clear the zeropad in the sockaddr */
+ bzero(sin->sin_zero, sizeof(sin->sin_zero));
+
if (!((so->so_options & SO_BINDANY) ||
(sin->sin_addr.s_addr == INADDR_BROADCAST &&
so->so_type == SOCK_DGRAM))) {