Mercurial > dropbear
comparison process-packet.c @ 886:cbc73a5aefb0
requirenext doesn't need two values
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 23 Jan 2014 22:25:52 +0800 |
parents | 19ce21bd198a |
children | bae0b34bc059 b8208506322e |
comparison
equal
deleted
inserted
replaced
885:19ce21bd198a | 886:cbc73a5aefb0 |
---|---|
72 dropbear_close("Disconnect received"); | 72 dropbear_close("Disconnect received"); |
73 } | 73 } |
74 | 74 |
75 /* This applies for KEX, where the spec says the next packet MUST be | 75 /* This applies for KEX, where the spec says the next packet MUST be |
76 * NEWKEYS */ | 76 * NEWKEYS */ |
77 if (ses.requirenext[0] != 0) { | 77 if (ses.requirenext != 0) { |
78 if (ses.requirenext[0] == type || ses.requirenext[1] == type) | 78 if (ses.requirenext == type) |
79 { | 79 { |
80 /* Got what we expected */ | 80 /* Got what we expected */ |
81 TRACE(("got expeced packet %d during kexinit", type)) | 81 TRACE(("got expected packet %d during kexinit", type)) |
82 ses.requirenext[0] = 0; | |
83 ses.requirenext[1] = 0; | |
84 } | 82 } |
85 else | 83 else |
86 { | 84 { |
87 /* RFC4253 7.1 - various messages are allowed at this point. | 85 /* RFC4253 7.1 - various messages are allowed at this point. |
88 The only ones we know about have already been handled though, | 86 The only ones we know about have already been handled though, |
97 goto out; | 95 goto out; |
98 } | 96 } |
99 else | 97 else |
100 { | 98 { |
101 TRACE(("disallowed packet during kexinit")) | 99 TRACE(("disallowed packet during kexinit")) |
102 dropbear_exit("Unexpected packet type %d, expected [%d,%d]", type, | 100 dropbear_exit("Unexpected packet type %d, expected %d", type, |
103 ses.requirenext[0], ses.requirenext[1]); | 101 ses.requirenext); |
104 } | 102 } |
105 } | 103 } |
106 } | 104 } |
107 | 105 |
108 /* Check if we should ignore this packet. Used currently only for | 106 /* Check if we should ignore this packet. Used currently only for |
109 * KEX code, with first_kex_packet_follows */ | 107 * KEX code, with first_kex_packet_follows */ |
110 if (ses.ignorenext) { | 108 if (ses.ignorenext) { |
111 TRACE(("Ignoring packet, type = %d", type)) | 109 TRACE(("Ignoring packet, type = %d", type)) |
112 ses.ignorenext = 0; | 110 ses.ignorenext = 0; |
113 goto out; | 111 goto out; |
112 } | |
113 | |
114 /* Only clear the flag after we have checked ignorenext */ | |
115 if (ses.requirenext != 0 && ses.requirenext == type) | |
116 { | |
117 ses.requirenext = 0; | |
114 } | 118 } |
115 | 119 |
116 | 120 |
117 /* Kindly the protocol authors gave all the preauth packets type values | 121 /* Kindly the protocol authors gave all the preauth packets type values |
118 * less-than-or-equal-to 60 ( == MAX_UNAUTH_PACKET_TYPE ). | 122 * less-than-or-equal-to 60 ( == MAX_UNAUTH_PACKET_TYPE ). |