diff packet.c @ 623:895fbe068f2c

Fix case where "-K 1" would cause a SSH_MSG_IGNORE packet to be sent with the wrong encryption key ("bad packet length" symptom) while key exchange was happening.
author Matt Johnston <matt@ucc.asn.au>
date Tue, 07 Jun 2011 11:55:44 +0000
parents 53c21d4ec98a
children f4232b65b316
line wrap: on
line diff
--- a/packet.c	Tue Jun 07 11:08:47 2011 +0000
+++ b/packet.c	Tue Jun 07 11:55:44 2011 +0000
@@ -441,10 +441,16 @@
 
 	TRACE(("encrypt_packet type is %d", packet_type))
 	
-	if (!ses.dataallowed && !packet_is_okay_kex(packet_type)) {
+	if ((!ses.dataallowed && !packet_is_okay_kex(packet_type))
+			|| ses.kexstate.sentnewkeys) {
 		/* During key exchange only particular packets are allowed.
 			Since this packet_type isn't OK we just enqueue it to send 
 			after the KEX, see maybe_flush_reply_queue */
+
+		/* We also enqueue packets here when we have sent a MSG_NEWKEYS
+		 * packet but are yet to received one. For simplicity we just switch
+		 * over all the keys at once. This is the 'ses.kexstate.sentnewkeys'
+		 * case. */
 		enqueue_reply_packet();
 		return;
 	}