summaryrefslogtreecommitdiffstats
path: root/sys/netinet/raw_ip.c
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2013-03-31 11:18:35 +0000
committerbluhm <bluhm@openbsd.org>2013-03-31 11:18:35 +0000
commitae39fdefb07f899fb0eca4b9a5449774dc9da4f8 (patch)
treeeada1234f7c138eee3724394df14e9c639c0aab0 /sys/netinet/raw_ip.c
parentProvide default resource allocation and free functions. Convert all (diff)
downloadwireguard-openbsd-ae39fdefb07f899fb0eca4b9a5449774dc9da4f8.tar.xz
wireguard-openbsd-ae39fdefb07f899fb0eca4b9a5449774dc9da4f8.zip
The call to in_pcballoc() in user request attach was handled in
three different ways. Use the same code in udp_usrreq() and rip_usrreq() and rip6_usrreq(). This also fixes a pcb and socket leak in udp_usrreq() in case soreserve() fails. Put an splsoftassert() into in_pcballoc() for safety. OK mpi@
Diffstat (limited to 'sys/netinet/raw_ip.c')
-rw-r--r--sys/netinet/raw_ip.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 502eecd7ad8..4f3bbc95285 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip.c,v 1.63 2013/03/30 12:15:29 bluhm Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.64 2013/03/31 11:18:35 bluhm Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
@@ -396,8 +396,9 @@ int
rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
struct mbuf *control, struct proc *p)
{
- int error = 0;
struct inpcb *inp = sotoinpcb(so);
+ int error = 0;
+ int s;
#ifdef MROUTING
extern struct socket *ip_mrouter;
#endif
@@ -423,9 +424,13 @@ rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
error = EPROTONOSUPPORT;
break;
}
+ s = splsoftnet();
if ((error = soreserve(so, rip_sendspace, rip_recvspace)) ||
- (error = in_pcballoc(so, &rawcbtable)))
+ (error = in_pcballoc(so, &rawcbtable))) {
+ splx(s);
break;
+ }
+ splx(s);
inp = (struct inpcb *)so->so_pcb;
inp->inp_ip.ip_p = (long)nam;
break;