diff options
author | 1998-02-25 03:45:14 +0000 | |
---|---|---|
committer | 1998-02-25 03:45:14 +0000 | |
commit | 68de8677483cf5db60c2729ed3d9b27586e6fc1f (patch) | |
tree | ef3a8250993f747194315d17720fe41514ca39e2 /sys/netinet/tcp_usrreq.c | |
parent | bye bye ap lkm (diff) | |
download | wireguard-openbsd-68de8677483cf5db60c2729ed3d9b27586e6fc1f.tar.xz wireguard-openbsd-68de8677483cf5db60c2729ed3d9b27586e6fc1f.zip |
Disallow TCP connects to 255.255.255.255 or local broadcast addresses.
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 50df2eea2af..14f360265bd 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.16 1998/01/24 18:21:39 mickey Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.17 1998/02/25 03:45:15 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 = mtod(nam, struct sockaddr_in *); register struct inpcb *inp; register struct tcpcb *tp = NULL; int s; @@ -189,6 +190,13 @@ tcp_usrreq(so, req, m, nam, control) * Send initial segment on connection. */ case PRU_CONNECT: + /* 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 +205,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); |