Mercurial > dropbear
comparison fuzz-wrapfd.c @ 1739:13d834efc376 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 15 Oct 2020 19:55:15 +0800 |
parents | 60fceff95858 |
children | dfbe947bdf0d |
comparison
equal
deleted
inserted
replaced
1562:768ebf737aa0 | 1739:13d834efc376 |
---|---|
1 #define FUZZ_SKIP_WRAP 1 | 1 #define FUZZ_SKIP_WRAP 1 |
2 #include "includes.h" | 2 #include "includes.h" |
3 #include "fuzz-wrapfd.h" | 3 #include "fuzz-wrapfd.h" |
4 | 4 |
5 #include "dbutil.h" | |
6 | |
5 #include "fuzz.h" | 7 #include "fuzz.h" |
6 | 8 |
7 #define IOWRAP_MAXFD (FD_SETSIZE-1) | 9 #define IOWRAP_MAXFD (FD_SETSIZE-1) |
8 static const int MAX_RANDOM_IN = 50000; | 10 static const int MAX_RANDOM_IN = 50000; |
9 static const double CHANCE_CLOSE = 1.0 / 300; | 11 static const double CHANCE_CLOSE = 1.0 / 600; |
10 static const double CHANCE_INTR = 1.0 / 200; | 12 static const double CHANCE_INTR = 1.0 / 900; |
11 static const double CHANCE_READ1 = 0.6; | 13 static const double CHANCE_READ1 = 0.96; |
12 static const double CHANCE_READ2 = 0.3; | 14 static const double CHANCE_READ2 = 0.5; |
13 static const double CHANCE_WRITE1 = 0.8; | 15 static const double CHANCE_WRITE1 = 0.96; |
14 static const double CHANCE_WRITE2 = 0.3; | 16 static const double CHANCE_WRITE2 = 0.5; |
15 | 17 |
16 struct fdwrap { | 18 struct fdwrap { |
17 enum wrapfd_mode mode; | 19 enum wrapfd_mode mode; |
18 buffer *buf; | 20 buffer *buf; |
19 int closein; | 21 int closein; |
24 /* for quick selection of in-use descriptors */ | 26 /* for quick selection of in-use descriptors */ |
25 static int wrap_used[IOWRAP_MAXFD+1]; | 27 static int wrap_used[IOWRAP_MAXFD+1]; |
26 static unsigned int nused; | 28 static unsigned int nused; |
27 static unsigned short rand_state[3]; | 29 static unsigned short rand_state[3]; |
28 | 30 |
29 void wrapfd_setup() { | 31 void wrapfd_setup(void) { |
30 TRACE(("wrapfd_setup")) | 32 TRACE(("wrapfd_setup")) |
31 nused = 0; | 33 nused = 0; |
32 memset(wrap_fds, 0x0, sizeof(wrap_fds)); | 34 memset(wrap_fds, 0x0, sizeof(wrap_fds)); |
33 memset(wrap_used, 0x0, sizeof(wrap_used)); | 35 memset(wrap_used, 0x0, sizeof(wrap_used)); |
34 | 36 |
193 assert(wrap_fds[i].mode != UNUSED); | 195 assert(wrap_fds[i].mode != UNUSED); |
194 fdlist[nset] = i; | 196 fdlist[nset] = i; |
195 nset++; | 197 nset++; |
196 } | 198 } |
197 } | 199 } |
198 FD_ZERO(readfds); | 200 DROPBEAR_FD_ZERO(readfds); |
199 | 201 |
200 if (nset > 0) { | 202 if (nset > 0) { |
201 /* set one */ | 203 /* set one */ |
202 sel = fdlist[nrand48(rand_state) % nset]; | 204 sel = fdlist[nrand48(rand_state) % nset]; |
203 FD_SET(sel, readfds); | 205 FD_SET(sel, readfds); |
220 assert(wrap_fds[i].mode != UNUSED); | 222 assert(wrap_fds[i].mode != UNUSED); |
221 fdlist[nset] = i; | 223 fdlist[nset] = i; |
222 nset++; | 224 nset++; |
223 } | 225 } |
224 } | 226 } |
225 FD_ZERO(writefds); | 227 DROPBEAR_FD_ZERO(writefds); |
226 | 228 |
227 /* set one */ | 229 /* set one */ |
228 if (nset > 0) { | 230 if (nset > 0) { |
229 sel = fdlist[nrand48(rand_state) % nset]; | 231 sel = fdlist[nrand48(rand_state) % nset]; |
230 FD_SET(sel, writefds); | 232 FD_SET(sel, writefds); |