source: zzuf/trunk/src/libzzuf.h @ 2521

Last change on this file since 2521 was 2521, checked in by Sam Hocevar, 12 years ago
  • Set a default maximum memory usage value to avoid excessive swapping.
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1/*
2 *  zzuf - general purpose fuzzer
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: libzzuf.h 2521 2008-07-15 20:15:35Z 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/* The default maximum memory usage is 1024 MiB. If this value is not set,
35 * zzuf may bring a machine down to its knees because of I/O. */
36#define DEFAULT_MEM 1024
37
38struct fuzz
39{
40    uint32_t seed;
41    double ratio;
42    int64_t cur;
43#ifdef HAVE_FGETLN
44    char *tmp;
45#endif
46    int uflag; int64_t upos; uint8_t uchar; /* ungetc stuff */
47    uint8_t data[CHUNKBYTES];
48};
49
50/* Internal variables */
51extern int _zz_ready;
52extern int _zz_disabled;
53extern int _zz_debugfd;
54extern int _zz_signal;
55extern int _zz_memory;
56extern int _zz_network;
57extern int _zz_autoinc;
58
59/* This function is needed to initialise memory functions */
60extern void _zz_mem_init(void);
61
Note: See TracBrowser for help on using the repository browser.