comparison dbrandom.c @ 1348:5c2899e35b63 fuzz

fuzz harness
author Matt Johnston <matt@ucc.asn.au>
date Sat, 13 May 2017 22:50:54 +0800
parents b28624698130
children 3fdd8c5a0195
comparison
equal deleted inserted replaced
1347:b28624698130 1348:5c2899e35b63
26 #include "buffer.h" 26 #include "buffer.h"
27 #include "dbutil.h" 27 #include "dbutil.h"
28 #include "bignum.h" 28 #include "bignum.h"
29 #include "dbrandom.h" 29 #include "dbrandom.h"
30 #include "runopts.h" 30 #include "runopts.h"
31 #include "fuzz.h"
31 32
32 33
33 /* this is used to generate unique output from the same hashpool */ 34 /* this is used to generate unique output from the same hashpool */
34 static uint32_t counter = 0; 35 static uint32_t counter = 0;
35 /* the max value for the counter, so it won't integer overflow */ 36 /* the max value for the counter, so it won't integer overflow */
145 void addrandom(unsigned char * buf, unsigned int len) 146 void addrandom(unsigned char * buf, unsigned int len)
146 { 147 {
147 hash_state hs; 148 hash_state hs;
148 149
149 #ifdef DROPBEAR_FUZZ 150 #ifdef DROPBEAR_FUZZ
150 if (opts.fuzz.fuzzing || opts.fuzz.recordf) { 151 if (fuzz.fuzzing || fuzz.recordf) {
151 return; 152 return;
152 } 153 }
153 #endif 154 #endif
154 155
155 /* hash in the new seed data */ 156 /* hash in the new seed data */
163 } 164 }
164 165
165 static void write_urandom() 166 static void write_urandom()
166 { 167 {
167 #ifdef DROPBEAR_FUZZ 168 #ifdef DROPBEAR_FUZZ
168 if (opts.fuzz.fuzzing || opts.fuzz.recordf) { 169 if (fuzz.fuzzing || fuzz.recordf) {
169 return; 170 return;
170 } 171 }
171 #endif 172 #endif
172 #ifndef DROPBEAR_PRNGD_SOCKET 173 #ifndef DROPBEAR_PRNGD_SOCKET
173 /* This is opportunistic, don't worry about failure */ 174 /* This is opportunistic, don't worry about failure */
201 pid_t pid; 202 pid_t pid;
202 struct timeval tv; 203 struct timeval tv;
203 clock_t clockval; 204 clock_t clockval;
204 205
205 #ifdef DROPBEAR_FUZZ 206 #ifdef DROPBEAR_FUZZ
206 if (opts.fuzz.fuzzing || opts.fuzz.recordf) { 207 if (fuzz.fuzzing || fuzz.recordf) {
207 seedfuzz(); 208 seedfuzz();
208 return; 209 return;
209 } 210 }
210 #endif 211 #endif
211 212