1 | /* |
---|
2 | * zzuf - general purpose fuzzer |
---|
3 | * Copyright (c) 2006 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: libzzuf.h 1668 2007-01-14 20:17:45Z 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 use file descriptor 17 as the debug channel */ |
---|
20 | #define DEBUG_FILENO 17 |
---|
21 | |
---|
22 | /* We arbitrarily split files into 1024-byte chunks. Each chunk has an |
---|
23 | * associated seed that can be computed from the zzuf seed, the chunk |
---|
24 | * index and the fuzziness density. This allows us to predictably fuzz |
---|
25 | * any part of the file without reading the whole file. */ |
---|
26 | #define CHUNKBYTES 1024 |
---|
27 | |
---|
28 | /* Default seed is 0. Why not? */ |
---|
29 | #define DEFAULT_SEED 0 |
---|
30 | |
---|
31 | /* The default fuzzing ratio is, arbitrarily, 0.4% */ |
---|
32 | #define DEFAULT_RATIO 0.004f |
---|
33 | #define MIN_RATIO 0.00001f |
---|
34 | #define MAX_RATIO 5.0f |
---|
35 | |
---|
36 | struct fuzz |
---|
37 | { |
---|
38 | uint32_t seed; |
---|
39 | float ratio; |
---|
40 | int cur; |
---|
41 | #ifdef HAVE_FGETLN |
---|
42 | char *tmp; |
---|
43 | #endif |
---|
44 | uint8_t data[CHUNKBYTES]; |
---|
45 | }; |
---|
46 | |
---|
47 | /* Internal variables */ |
---|
48 | extern int _zz_ready; |
---|
49 | extern int _zz_disabled; |
---|
50 | extern int _zz_hasdebug; |
---|
51 | extern int _zz_signal; |
---|
52 | extern int _zz_memory; |
---|
53 | extern int _zz_network; |
---|
54 | extern int _zz_autoinc; |
---|
55 | |
---|
56 | /* Library initialisation shit */ |
---|
57 | extern void _zz_init(void) __attribute__((constructor)); |
---|
58 | extern void _zz_fini(void) __attribute__((destructor)); |
---|
59 | |
---|