| 1 | /* |
|---|
| 2 | * zzuf - general purpose fuzzer |
|---|
| 3 | * Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net> |
|---|
| 4 | * All Rights Reserved |
|---|
| 5 | * |
|---|
| 6 | * $Id$ |
|---|
| 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 | * common.h: default fuzzing settings |
|---|
| 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 | |
|---|
| 38 | /* We use file descriptor 17 as the debug channel */ |
|---|
| 39 | #define DEBUG_FILENO 17 |
|---|
| 40 | #define DEBUG_FILENO_STR "17" |
|---|
| 41 | |
|---|
| 42 | struct fuzz |
|---|
| 43 | { |
|---|
| 44 | uint32_t seed; |
|---|
| 45 | double ratio; |
|---|
| 46 | int64_t cur; |
|---|
| 47 | #ifdef HAVE_FGETLN |
|---|
| 48 | char *tmp; |
|---|
| 49 | #endif |
|---|
| 50 | int uflag; int64_t upos; uint8_t uchar; /* ungetc stuff */ |
|---|
| 51 | uint8_t data[CHUNKBYTES]; |
|---|
| 52 | }; |
|---|
| 53 | |
|---|