diff options
author | phk <phk@FreeBSD.org> | 2000-09-17 11:34:33 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2000-09-17 11:34:33 +0000 |
commit | f0509c05efb30c85fadfd8ef036298ea187cfeaf (patch) | |
tree | 054939070a06b8c4ce19f151d40c52519a2f92aa /sys/netinet | |
parent | c4bf7b152c0233d1b523829b3d5a9d6e710b8c8b (diff) | |
download | FreeBSD-src-f0509c05efb30c85fadfd8ef036298ea187cfeaf.zip FreeBSD-src-f0509c05efb30c85fadfd8ef036298ea187cfeaf.tar.gz |
Make sure UDP sockets are explicitly bind(2)'ed [sic] before we connect(2)
them.
PR: 20946
Isolated by: Aaron Gifford <agifford@infowest.com>
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/udp_usrreq.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 07b1166..6a86879 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -827,10 +827,15 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct proc *p) return EINVAL; if (inp->inp_faddr.s_addr != INADDR_ANY) return EISCONN; + error = 0; s = splnet(); - sin = (struct sockaddr_in *)nam; - prison_remote_ip(p, 0, &sin->sin_addr.s_addr); - error = in_pcbconnect(inp, nam, p); + if (inp->inp_laddr.s_addr == INADDR_ANY && p->p_prison != NULL) + error = in_pcbbind(inp, NULL, p); + if (error == 0) { + sin = (struct sockaddr_in *)nam; + prison_remote_ip(p, 0, &sin->sin_addr.s_addr); + error = in_pcbconnect(inp, nam, p); + } splx(s); if (error == 0) soisconnected(so); |