diff options
author | 2000-02-29 05:25:53 +0000 | |
---|---|---|
committer | 2000-02-29 05:25:53 +0000 | |
commit | f2f33c6103978b489b7cb63b77e5cd7b12b71a82 (patch) | |
tree | dc40b455200d9991b3ad60d5b711402f6bd1a5c8 /sys/netinet/tcp_subr.c | |
parent | Various cleanup. (diff) | |
download | wireguard-openbsd-f2f33c6103978b489b7cb63b77e5cd7b12b71a82.tar.xz wireguard-openbsd-f2f33c6103978b489b7cb63b77e5cd7b12b71a82.zip |
ensure tcp window size does not overflow (16bit unsigned after window scale).
FreeBSD PR: 16914
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r-- | sys/netinet/tcp_subr.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index eb09b426e86..c87800e1e02 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_subr.c,v 1.23 1999/12/29 20:27:55 mickey Exp $ */ +/* $OpenBSD: tcp_subr.c,v 1.24 2000/02/29 05:25:53 itojun Exp $ */ /* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */ /* @@ -375,9 +375,10 @@ tcp_respond(tp, template, m, ack, seq, flags) th->th_off = sizeof (struct tcphdr) >> 2; th->th_flags = flags; if (tp) - th->th_win = htons((u_int16_t) (win >> tp->rcv_scale)); - else - th->th_win = htons((u_int16_t)win); + win >>= tp->rcv_scale; + if (win > TCP_MAXWIN) + win = TCP_MAXWIN; + th->th_win = htons((u_int16_t)win); th->th_urp = 0; #ifdef INET6 |