comparison packet.c @ 1558:2f64cb3d3007 fuzz

- #if not #ifdef for DROPBEAR_FUZZ - fix some unused variables
author Matt Johnston <matt@ucc.asn.au>
date Wed, 28 Feb 2018 21:40:08 +0800
parents 5916af64acd4
children 92c93b4a3646
comparison
equal deleted inserted replaced
1557:61a793b6e471 1558:2f64cb3d3007
75 75
76 packet_queue_to_iovec(&ses.writequeue, iov, &iov_count); 76 packet_queue_to_iovec(&ses.writequeue, iov, &iov_count);
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 #ifdef 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 }
103 if (written == 0) { 103 if (written == 0) {
104 ses.remoteclosed(); 104 ses.remoteclosed();
105 } 105 }
106 106
107 #else /* No writev () */ 107 #else /* No writev () */
108 #ifdef DROPBEAR_FUZZ 108 #if DROPBEAR_FUZZ
109 _Static_assert(0, "No fuzzing code for no-writev writes"); 109 _Static_assert(0, "No fuzzing code for no-writev writes");
110 #endif 110 #endif
111 /* Get the next buffer in the queue of encrypted packets to write*/ 111 /* Get the next buffer in the queue of encrypted packets to write*/
112 writebuf = (buffer*)examine(&ses.writequeue); 112 writebuf = (buffer*)examine(&ses.writequeue);
113 113
364 contents_len = ses.readbuf->len - mac_size; 364 contents_len = ses.readbuf->len - mac_size;
365 365
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 #ifdef 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) {