diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-08-11 19:53:03 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2017-08-11 19:53:03 +0000 |
commit | 80ea0fdcccada4edc03c233308577d3cdffa73fe (patch) | |
tree | 3e0a37b5d04229eb6343d2c414a648a0eb02d1bc /sys/netinet/udp_usrreq.c | |
parent | 9352f67a254d317d6f2624bfc0f8f5d688d1f490 (diff) |
Validate sockaddr from userland in central functions. This results
in common checks for unix, inet, inet6 instead of partial checks
here and there. Some checks are already done at a higher layer,
but better be paranoid with user input.
OK claudio@ millert@
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r-- | sys/netinet/udp_usrreq.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 9700554b3ab..486b8d176e0 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.238 2017/06/26 09:32:32 mpi Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.239 2017/08/11 19:53:02 bluhm Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -960,26 +960,16 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct mbuf *addr, } if (addr) { - sin = mtod(addr, struct sockaddr_in *); - - if (addr->m_len != sizeof(*sin)) { - error = EINVAL; - goto release; - } - if (sin->sin_family != AF_INET) { - error = EAFNOSUPPORT; + if ((error = in_nam2sin(addr, &sin))) goto release; - } if (sin->sin_port == 0) { error = EADDRNOTAVAIL; goto release; } - if (inp->inp_faddr.s_addr != INADDR_ANY) { error = EISCONN; goto release; } - error = in_pcbselsrc(&laddr, sin, inp); if (error) goto release; |