summaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_usrreq.c
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>1998-02-28 03:39:59 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>1998-02-28 03:39:59 +0000
commit262293116abe08f018916660cb8435e3f56fe679 (patch)
treea5ad7729b9ef11144e5eaf6ea661ce4e8912ac81 /sys/netinet/tcp_usrreq.c
parent48d3dba576d9a3c4f87e56e191bd848b13edb13d (diff)
Another shot at disallowing TCP connections to 255.255.255.255,
0.0.0.0 and any local broadcast addresses. Tested.
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r--sys/netinet/tcp_usrreq.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 6956fc9c7a7..2b89813c071 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.19 1998/02/25 23:44:58 deraadt Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.20 1998/02/28 03:39:58 angelos Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -90,6 +90,7 @@ tcp_usrreq(so, req, m, nam, control)
int req;
struct mbuf *m, *nam, *control;
{
+ struct sockaddr_in *sin;
register struct inpcb *inp;
register struct tcpcb *tp = NULL;
int s;
@@ -189,6 +190,15 @@ tcp_usrreq(so, req, m, nam, control)
* Send initial segment on connection.
*/
case PRU_CONNECT:
+ sin = mtod(nam, struct sockaddr_in *);
+
+ /* Trying to connect to some broadcast address */
+ if (in_broadcast(sin->sin_addr, NULL))
+ {
+ error = EINVAL;
+ break;
+ }
+
if (inp->inp_lport == 0) {
error = in_pcbbind(inp, NULL);
if (error)
@@ -197,6 +207,7 @@ tcp_usrreq(so, req, m, nam, control)
error = in_pcbconnect(inp, nam);
if (error)
break;
+
tp->t_template = tcp_template(tp);
if (tp->t_template == 0) {
in_pcbdisconnect(inp);