Mercurial > dropbear
comparison process-packet.c @ 801:7dcb46da72d9 ecc
merge in HEAD
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 21 May 2013 12:09:35 +0800 |
parents | 96b8bcb88017 |
children | 220f55d540ae |
comparison
equal
deleted
inserted
replaced
799:c344607b7341 | 801:7dcb46da72d9 |
---|---|
43 void process_packet() { | 43 void process_packet() { |
44 | 44 |
45 unsigned char type; | 45 unsigned char type; |
46 unsigned int i; | 46 unsigned int i; |
47 | 47 |
48 TRACE(("enter process_packet")) | 48 TRACE2(("enter process_packet")) |
49 | 49 |
50 type = buf_getbyte(ses.payload); | 50 type = buf_getbyte(ses.payload); |
51 TRACE(("process_packet: packet type = %d", type)) | 51 TRACE(("process_packet: packet type = %d, len %d", type, ses.payload->len)) |
52 | 52 |
53 ses.lastpacket = type; | 53 ses.lastpacket = type; |
54 | 54 |
55 ses.last_packet_time = time(NULL); | 55 ses.last_packet_time = time(NULL); |
56 | 56 |
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) { | 77 if (ses.requirenext[0] != 0) { |
78 if (ses.requirenext != type) { | 78 if (ses.requirenext[0] != type |
79 /* TODO send disconnect? */ | 79 && (ses.requirenext[1] == 0 || ses.requirenext[1] != type)) { |
80 dropbear_exit("Unexpected packet type %d, expected %d", type, | 80 dropbear_exit("Unexpected packet type %d, expected [%d,%d]", type, |
81 ses.requirenext); | 81 ses.requirenext[0], ses.requirenext[1]); |
82 } else { | 82 } else { |
83 /* Got what we expected */ | 83 /* Got what we expected */ |
84 ses.requirenext = 0; | 84 ses.requirenext[0] = 0; |
85 ses.requirenext[1] = 0; | |
85 } | 86 } |
86 } | 87 } |
87 | 88 |
88 /* Check if we should ignore this packet. Used currently only for | 89 /* Check if we should ignore this packet. Used currently only for |
89 * KEX code, with first_kex_packet_follows */ | 90 * KEX code, with first_kex_packet_follows */ |
121 | 122 |
122 out: | 123 out: |
123 buf_free(ses.payload); | 124 buf_free(ses.payload); |
124 ses.payload = NULL; | 125 ses.payload = NULL; |
125 | 126 |
126 TRACE(("leave process_packet")) | 127 TRACE2(("leave process_packet")) |
127 } | 128 } |
128 | 129 |
129 | 130 |
130 | 131 |
131 /* This must be called directly after receiving the unimplemented packet. | 132 /* This must be called directly after receiving the unimplemented packet. |