1 | /* |
---|
2 | * zzuf - general purpose fuzzer |
---|
3 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: libzzuf.h 2272 2008-04-12 07:44:34Z sam $ |
---|
7 | * |
---|
8 | * This program is free software. It comes without any warranty, to |
---|
9 | * the extent permitted by applicable law. You can redistribute it |
---|
10 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
11 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
12 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
13 | */ |
---|
14 | |
---|
15 | /* |
---|
16 | * libzzuf.h: preloaded wrapper library |
---|
17 | */ |
---|
18 | |
---|
19 | /* We arbitrarily split files into 1024-byte chunks. Each chunk has an |
---|
20 | * associated seed that can be computed from the zzuf seed, the chunk |
---|
21 | * index and the fuzziness density. This allows us to predictably fuzz |
---|
22 | * any part of the file without reading the whole file. */ |
---|
23 | #define CHUNKBYTES 1024 |
---|
24 | |
---|
25 | /* Default seed is 0. Why not? */ |
---|
26 | #define DEFAULT_SEED 0 |
---|
27 | |
---|
28 | /* The default fuzzing ratio is, arbitrarily, 0.4%. The minimal fuzzing |
---|
29 | * ratio is 0.000000001% (less than one bit changed on a whole DVD). */ |
---|
30 | #define DEFAULT_RATIO 0.004 |
---|
31 | #define MIN_RATIO 0.00000000001 |
---|
32 | #define MAX_RATIO 5.0 |
---|
33 | |
---|
34 | struct fuzz |
---|
35 | { |
---|
36 | uint32_t seed; |
---|
37 | double ratio; |
---|
38 | int64_t cur; |
---|
39 | #ifdef HAVE_FGETLN |
---|
40 | char *tmp; |
---|
41 | #endif |
---|
42 | int uflag; int64_t upos; uint8_t uchar; /* ungetc stuff */ |
---|
43 | uint8_t data[CHUNKBYTES]; |
---|
44 | }; |
---|
45 | |
---|
46 | /* Internal variables */ |
---|
47 | extern int _zz_ready; |
---|
48 | extern int _zz_disabled; |
---|
49 | extern int _zz_debugfd; |
---|
50 | extern int _zz_signal; |
---|
51 | extern int _zz_memory; |
---|
52 | extern int _zz_network; |
---|
53 | extern int _zz_autoinc; |
---|
54 | |
---|
55 | /* This function is needed to initialise memory functions */ |
---|
56 | extern void _zz_mem_init(void); |
---|
57 | |
---|