comparison packet.c @ 594:a98a2138364a

Improve capitalisation for all logged strings
author Matt Johnston <matt@ucc.asn.au>
date Wed, 23 Feb 2011 15:50:30 +0000
parents afb089e70892
children 53c21d4ec98a
comparison
equal deleted inserted replaced
593:ea103e4476ce 594:a98a2138364a
73 if (written < 0) { 73 if (written < 0) {
74 if (errno == EINTR) { 74 if (errno == EINTR) {
75 TRACE(("leave writepacket: EINTR")) 75 TRACE(("leave writepacket: EINTR"))
76 return; 76 return;
77 } else { 77 } else {
78 dropbear_exit("error writing"); 78 dropbear_exit("Error writing");
79 } 79 }
80 } 80 }
81 81
82 now = time(NULL); 82 now = time(NULL);
83 ses.last_trx_packet_time = now; 83 ses.last_trx_packet_time = now;
142 if (len < 0) { 142 if (len < 0) {
143 if (errno == EINTR || errno == EAGAIN) { 143 if (errno == EINTR || errno == EAGAIN) {
144 TRACE(("leave read_packet: EINTR or EAGAIN")) 144 TRACE(("leave read_packet: EINTR or EAGAIN"))
145 return; 145 return;
146 } else { 146 } else {
147 dropbear_exit("error reading: %s", strerror(errno)); 147 dropbear_exit("Error reading: %s", strerror(errno));
148 } 148 }
149 } 149 }
150 150
151 buf_incrpos(ses.readbuf, len); 151 buf_incrpos(ses.readbuf, len);
152 152
191 if (slen < 0) { 191 if (slen < 0) {
192 if (errno == EINTR) { 192 if (errno == EINTR) {
193 TRACE(("leave read_packet_init: EINTR")) 193 TRACE(("leave read_packet_init: EINTR"))
194 return DROPBEAR_FAILURE; 194 return DROPBEAR_FAILURE;
195 } 195 }
196 dropbear_exit("error reading: %s", strerror(errno)); 196 dropbear_exit("Error reading: %s", strerror(errno));
197 } 197 }
198 198
199 buf_incrwritepos(ses.readbuf, slen); 199 buf_incrwritepos(ses.readbuf, slen);
200 200
201 if ((unsigned int)slen != maxlen) { 201 if ((unsigned int)slen != maxlen) {
208 buf_setpos(ses.readbuf, 0); 208 buf_setpos(ses.readbuf, 0);
209 if (ses.keys->recv.crypt_mode->decrypt(buf_getptr(ses.readbuf, blocksize), 209 if (ses.keys->recv.crypt_mode->decrypt(buf_getptr(ses.readbuf, blocksize),
210 buf_getwriteptr(ses.readbuf, blocksize), 210 buf_getwriteptr(ses.readbuf, blocksize),
211 blocksize, 211 blocksize,
212 &ses.keys->recv.cipher_state) != CRYPT_OK) { 212 &ses.keys->recv.cipher_state) != CRYPT_OK) {
213 dropbear_exit("error decrypting"); 213 dropbear_exit("Error decrypting");
214 } 214 }
215 len = buf_getint(ses.readbuf) + 4 + macsize; 215 len = buf_getint(ses.readbuf) + 4 + macsize;
216 216
217 TRACE(("packet size is %d, block %d mac %d", len, blocksize, macsize)) 217 TRACE(("packet size is %d, block %d mac %d", len, blocksize, macsize))
218 218
219 219
220 /* check packet length */ 220 /* check packet length */
221 if ((len > RECV_MAX_PACKET_LEN) || 221 if ((len > RECV_MAX_PACKET_LEN) ||
222 (len < MIN_PACKET_LEN + macsize) || 222 (len < MIN_PACKET_LEN + macsize) ||
223 ((len - macsize) % blocksize != 0)) { 223 ((len - macsize) % blocksize != 0)) {
224 dropbear_exit("bad packet size %d", len); 224 dropbear_exit("Integrity error (bad packet size %d)", len);
225 } 225 }
226 226
227 if (len > ses.readbuf->size) { 227 if (len > ses.readbuf->size) {
228 buf_resize(ses.readbuf, len); 228 buf_resize(ses.readbuf, len);
229 } 229 }
254 if (ses.keys->recv.crypt_mode->decrypt( 254 if (ses.keys->recv.crypt_mode->decrypt(
255 buf_getptr(ses.readbuf, len), 255 buf_getptr(ses.readbuf, len),
256 buf_getwriteptr(ses.readbuf, len), 256 buf_getwriteptr(ses.readbuf, len),
257 len, 257 len,
258 &ses.keys->recv.cipher_state) != CRYPT_OK) { 258 &ses.keys->recv.cipher_state) != CRYPT_OK) {
259 dropbear_exit("error decrypting"); 259 dropbear_exit("Error decrypting");
260 } 260 }
261 buf_incrpos(ses.readbuf, len); 261 buf_incrpos(ses.readbuf, len);
262 262
263 /* check the hmac */ 263 /* check the hmac */
264 if (checkmac() != DROPBEAR_SUCCESS) { 264 if (checkmac() != DROPBEAR_SUCCESS) {
271 271
272 /* payload length */ 272 /* payload length */
273 /* - 4 - 1 is for LEN and PADLEN values */ 273 /* - 4 - 1 is for LEN and PADLEN values */
274 len = ses.readbuf->len - padlen - 4 - 1 - macsize; 274 len = ses.readbuf->len - padlen - 4 - 1 - macsize;
275 if ((len > RECV_MAX_PAYLOAD_LEN) || (len < 1)) { 275 if ((len > RECV_MAX_PAYLOAD_LEN) || (len < 1)) {
276 dropbear_exit("bad packet size"); 276 dropbear_exit("Bad packet size %d", len);
277 } 277 }
278 278
279 buf_setpos(ses.readbuf, PACKET_PAYLOAD_OFF); 279 buf_setpos(ses.readbuf, PACKET_PAYLOAD_OFF);
280 280
281 #ifndef DISABLE_ZLIB 281 #ifndef DISABLE_ZLIB
518 if (ses.keys->trans.crypt_mode->encrypt( 518 if (ses.keys->trans.crypt_mode->encrypt(
519 buf_getptr(writebuf, len), 519 buf_getptr(writebuf, len),
520 buf_getwriteptr(writebuf, len), 520 buf_getwriteptr(writebuf, len),
521 len, 521 len,
522 &ses.keys->trans.cipher_state) != CRYPT_OK) { 522 &ses.keys->trans.cipher_state) != CRYPT_OK) {
523 dropbear_exit("error encrypting"); 523 dropbear_exit("Error encrypting");
524 } 524 }
525 buf_incrpos(writebuf, len); 525 buf_incrpos(writebuf, len);
526 526
527 /* stick the MAC on it */ 527 /* stick the MAC on it */
528 buf_putbytes(writebuf, mac_bytes, mac_size); 528 buf_putbytes(writebuf, mac_bytes, mac_size);