1 /*
2  *  zzuf - general purpose fuzzer
3  *  Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
4  *                All Rights Reserved
5  *
6  *  This program is free software. It comes without any warranty, to
7  *  the extent permitted by applicable law. You can redistribute it
8  *  and/or modify it under the terms of the Do What The Fuck You Want
9  *  To Public License, Version 2, as published by Sam Hocevar. See
10  *  http://sam.zoy.org/wtfpl/COPYING for more details.
11  */
12 
13 /*
14  *  common.h: default fuzzing settings
15  */
16 
17 /* We arbitrarily split files into 1024-byte chunks. Each chunk has an
18  * associated seed that can be computed from the zzuf seed, the chunk
19  * index and the fuzziness density. This allows us to predictably fuzz
20  * any part of the file without reading the whole file. */
21 #define CHUNKBYTES 1024
22 
23 /* Default seed is 0. Why not? */
24 #define DEFAULT_SEED 0
25 
26 /* The default fuzzing ratio is, arbitrarily, 0.4%. The minimal fuzzing
27  * ratio is 0.000000001% (less than one bit changed on a whole DVD). */
28 #define DEFAULT_RATIO 0.004
29 #define MIN_RATIO 0.00000000001
30 #define MAX_RATIO 5.0
31 
32 /* The default maximum memory usage is 1024 MiB. If this value is not set,
33  * zzuf may bring a machine down to its knees because of I/O. */
34 #define DEFAULT_MEM 1024
35 
36 /* We use file descriptor 17 as the debug channel */
37 #define DEBUG_FILENO 17
38 #define DEBUG_FILENO_STR "17"
39 
40 struct fuzz
41 {
42     uint32_t seed;
43     double ratio;
44     int64_t cur;
45 #ifdef HAVE_FGETLN
46     char *tmp;
47 #endif
48     int uflag; int64_t upos; uint8_t uchar; /* ungetc stuff */
49     uint8_t data[CHUNKBYTES];
50 };
51 
52