diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2016-01-29 02:42:47 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2016-01-29 02:42:47 +0000 |
commit | 3a28ff64c2b3187e00d4a53255a62ce7c93c3452 (patch) | |
tree | ceec880b9c0a6ae2e396041f54d5817438a328f7 | |
parent | 3d10fc4842b2de3d2e00c77af21e4f6e3c9dbe73 (diff) |
Account for packets buffered but not yet processed when computing whether or
not it is time to perform rekeying. bz#2521, based loosely on a patch from
olo at fb.com, ok djm@
-rw-r--r-- | usr.bin/ssh/packet.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/ssh/packet.c b/usr.bin/ssh/packet.c index 101d2b4fa56..4d4c2cd7fca 100644 --- a/usr.bin/ssh/packet.c +++ b/usr.bin/ssh/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.222 2016/01/14 16:17:40 markus Exp $ */ +/* $OpenBSD: packet.c,v 1.223 2016/01/29 02:42:46 dtucker Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -2231,16 +2231,21 @@ int ssh_packet_need_rekeying(struct ssh *ssh) { struct session_state *state = ssh->state; + u_int32_t buf_in, buf_out; if (ssh->compat & SSH_BUG_NOREKEY) return 0; + buf_in = roundup(sshbuf_len(state->input), + state->newkeys[MODE_IN]->enc.block_size); + buf_out = roundup(sshbuf_len(state->output), + state->newkeys[MODE_OUT]->enc.block_size); return (state->p_send.packets > MAX_PACKETS) || (state->p_read.packets > MAX_PACKETS) || (state->max_blocks_out && - (state->p_send.blocks > state->max_blocks_out)) || + (state->p_send.blocks + buf_out > state->max_blocks_out)) || (state->max_blocks_in && - (state->p_read.blocks > state->max_blocks_in)) || + (state->p_read.blocks + buf_in > state->max_blocks_in)) || (state->rekey_interval != 0 && state->rekey_time + state->rekey_interval <= monotime()); } |