diff options
author | tegge <tegge@FreeBSD.org> | 1997-05-19 00:18:30 +0000 |
---|---|---|
committer | tegge <tegge@FreeBSD.org> | 1997-05-19 00:18:30 +0000 |
commit | ffb9c56f7662bb2fd416f5fa514795e0317af449 (patch) | |
tree | ab060b401886c8c2eae6790a9ad1d4bc3491f707 /sys/netinet | |
parent | a5235db2753a6b21c33273103f8425a0d3c65e8c (diff) | |
download | FreeBSD-src-ffb9c56f7662bb2fd416f5fa514795e0317af449.zip FreeBSD-src-ffb9c56f7662bb2fd416f5fa514795e0317af449.tar.gz |
Disallow network interrupts while the address is found and copied in
in_setsockaddr and in_setpeeraddr.
Handle the case where the socket was disconnected before the network
interrupts were disabled.
Reviewed by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/in_pcb.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 6ae7e85..4527e28 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)in_pcb.c 8.4 (Berkeley) 5/24/95 - * $Id: in_pcb.c,v 1.30 1997/04/03 05:14:40 davidg Exp $ + * $Id: in_pcb.c,v 1.31 1997/04/27 20:01:04 wollman Exp $ */ #include <sys/param.h> @@ -470,9 +470,14 @@ in_setsockaddr(so, nam) struct socket *so; struct mbuf *nam; { + int s = splnet(); register struct inpcb *inp = sotoinpcb(so); register struct sockaddr_in *sin; + if (!inp) { + splx(s); + return EINVAL; + } nam->m_len = sizeof (*sin); sin = mtod(nam, struct sockaddr_in *); bzero((caddr_t)sin, sizeof (*sin)); @@ -480,6 +485,7 @@ in_setsockaddr(so, nam) sin->sin_len = sizeof(*sin); sin->sin_port = inp->inp_lport; sin->sin_addr = inp->inp_laddr; + splx(s); return 0; } @@ -488,9 +494,14 @@ in_setpeeraddr(so, nam) struct socket *so; struct mbuf *nam; { + int s = splnet(); struct inpcb *inp = sotoinpcb(so); register struct sockaddr_in *sin; + if (!inp) { + splx(s); + return EINVAL; + } nam->m_len = sizeof (*sin); sin = mtod(nam, struct sockaddr_in *); bzero((caddr_t)sin, sizeof (*sin)); @@ -498,6 +509,7 @@ in_setpeeraddr(so, nam) sin->sin_len = sizeof(*sin); sin->sin_port = inp->inp_fport; sin->sin_addr = inp->inp_faddr; + splx(s); return 0; } |