Mercurial > dropbear
comparison fuzz-wrapfd.c @ 1610:96e4c9b2cc00 coverity
merge coverity
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 21 Mar 2018 00:52:02 +0800 |
parents | 60fceff95858 |
children | dfbe947bdf0d |
comparison
equal
deleted
inserted
replaced
1580:7f2be495dff6 | 1610:96e4c9b2cc00 |
---|---|
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; |
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); |