comparison packet.c @ 1559:92c93b4a3646 fuzz

Fix to be able to compile normal(ish) binaries with --enable-fuzz
author Matt Johnston <matt@ucc.asn.au>
date Wed, 28 Feb 2018 22:02:12 +0800
parents 2f64cb3d3007
children 399d8eb961b5
comparison
equal deleted inserted replaced
1558:2f64cb3d3007 1559:92c93b4a3646
77 /* This may return EAGAIN. The main loop sometimes 77 /* This may return EAGAIN. The main loop sometimes
78 calls write_packet() without bothering to test with select() since 78 calls write_packet() without bothering to test with select() since
79 it's likely to be necessary */ 79 it's likely to be necessary */
80 #if DROPBEAR_FUZZ 80 #if DROPBEAR_FUZZ
81 if (fuzz.fuzzing) { 81 if (fuzz.fuzzing) {
82 // pretend to write one packet at a time 82 /* pretend to write one packet at a time */
83 // TODO(fuzz): randomise amount written based on the fuzz input 83 /* TODO(fuzz): randomise amount written based on the fuzz input */
84 written = iov[0].iov_len; 84 written = iov[0].iov_len;
85 } 85 }
86 else 86 else
87 #endif 87 #endif
88 { 88 {
366 buf_setpos(ses.readbuf, 0); 366 buf_setpos(ses.readbuf, 0);
367 make_mac(ses.recvseq, &ses.keys->recv, ses.readbuf, contents_len, mac_bytes); 367 make_mac(ses.recvseq, &ses.keys->recv, ses.readbuf, contents_len, mac_bytes);
368 368
369 #if DROPBEAR_FUZZ 369 #if DROPBEAR_FUZZ
370 if (fuzz.fuzzing) { 370 if (fuzz.fuzzing) {
371 // fail 1 in 2000 times to test error path. 371 /* fail 1 in 2000 times to test error path.
372 // note that mac_bytes is all zero prior to kex, so don't test ==0 ! 372 note that mac_bytes is all zero prior to kex, so don't test ==0 ! */
373 unsigned int value = *((unsigned int*)&mac_bytes); 373 unsigned int value = *((unsigned int*)&mac_bytes);
374 if (value % 2000 == 99) { 374 if (value % 2000 == 99) {
375 return DROPBEAR_FAILURE; 375 return DROPBEAR_FAILURE;
376 } 376 }
377 return DROPBEAR_SUCCESS; 377 return DROPBEAR_SUCCESS;