diff options
author | 2019-11-11 21:17:21 +0000 | |
---|---|---|
committer | 2019-11-11 21:17:21 +0000 | |
commit | 32906ae91db3caccaf93ab1a09e427cff8587d06 (patch) | |
tree | fdcf4454cd1a95dc095bf432c86a1787385cbecc /sys/netinet/tcp_input.c | |
parent | skip demanding -fstack-protector-all on hppa. we never wrote a stack protector (diff) | |
download | wireguard-openbsd-32906ae91db3caccaf93ab1a09e427cff8587d06.tar.xz wireguard-openbsd-32906ae91db3caccaf93ab1a09e427cff8587d06.zip |
Prevent underflows in tp->snd_wnd if the remote side ACKs more than
tp->snd_wnd. This can happen, for example, when the remote side
responds to a window probe by ACKing the one byte it contains.
from FreeBSD; via markus@; OK sashan@ tobhe@
Diffstat (limited to 'sys/netinet/tcp_input.c')
-rw-r--r-- | sys/netinet/tcp_input.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index aeff9ed3b54..817576adada 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.361 2019/07/12 19:43:51 bluhm Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.362 2019/11/11 21:17:21 bluhm Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -1712,12 +1712,18 @@ trimthenstep6: } ND6_HINT(tp); if (acked > so->so_snd.sb_cc) { - tp->snd_wnd -= so->so_snd.sb_cc; + if (tp->snd_wnd > so->so_snd.sb_cc) + tp->snd_wnd -= so->so_snd.sb_cc; + else + tp->snd_wnd = 0; sbdrop(so, &so->so_snd, (int)so->so_snd.sb_cc); ourfinisacked = 1; } else { sbdrop(so, &so->so_snd, acked); - tp->snd_wnd -= acked; + if (tp->snd_wnd > acked) + tp->snd_wnd -= acked; + else + tp->snd_wnd = 0; ourfinisacked = 0; } |