rcolebaugh / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
8f2528
commit 0fb1a617a07b8df5de188dd5a0c8bf293d4bfc0e
8f2528
Author: markus@openbsd.org <markus@openbsd.org>
8f2528
Date:   Sat Mar 11 13:07:35 2017 +0000
8f2528
8f2528
    upstream commit
8f2528
    
8f2528
    Don't count the initial block twice when computing how
8f2528
    many bytes to discard for the work around for the attacks against CBC-mode.
8f2528
    ok djm@; report from Jean Paul, Kenny, Martin and Torben @ RHUL
8f2528
    
8f2528
    Upstream-ID: f445f509a4e0a7ba3b9c0dae7311cb42458dc1e2
8f2528
8f2528
diff --git a/packet.c b/packet.c
8f2528
index 01e2d45..2f3a2ec 100644
8f2528
--- a/packet.c
8f2528
+++ b/packet.c
8f2528
@@ -1850,11 +1850,11 @@ ssh_packet_read_poll2(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
8f2528
 			if (r != SSH_ERR_MAC_INVALID)
8f2528
 				goto out;
8f2528
 			logit("Corrupted MAC on input.");
8f2528
-			if (need > PACKET_MAX_SIZE)
8f2528
+			if (need + block_size > PACKET_MAX_SIZE)
8f2528
 				return SSH_ERR_INTERNAL_ERROR;
8f2528
 			return ssh_packet_start_discard(ssh, enc, mac,
8f2528
 			    sshbuf_len(state->incoming_packet),
8f2528
-			    PACKET_MAX_SIZE - need);
8f2528
+			    PACKET_MAX_SIZE - need - block_size);
8f2528
 		}
8f2528
 		/* Remove MAC from input buffer */
8f2528
 		DBG(debug("MAC #%d ok", state->p_read.seqnr));