source: zzuf/trunk/src/libzzuf.c @ 1672

Last change on this file since 1672 was 1672, checked in by Sam Hocevar, 16 years ago
  • Support ranges with the -r flag.
  • Property svn:keywords set to Id
File size: 2.5 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.c 1672 2007-01-14 23:41:03Z 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.c: preloaded wrapper library
17 */
18
19#include "config.h"
20#define _GNU_SOURCE
21
22#if defined HAVE_STDINT_H
23#   include <stdint.h>
24#elif defined HAVE_INTTYPES_H
25#   include <inttypes.h>
26#endif
27#include <stdio.h>
28#include <sys/types.h>
29#include <unistd.h>
30#include <stdlib.h>
31#include <string.h>
32#include <fcntl.h>
33
34#include <stdarg.h>
35#include <dlfcn.h>
36
37#include "libzzuf.h"
38#include "debug.h"
39#include "load.h"
40#include "fd.h"
41#include "fuzz.h"
42
43/* Global variables */
44int   _zz_ready    = 0;
45int   _zz_disabled = 0;
46int   _zz_hasdebug = 0;
47int   _zz_signal   = 0;
48int   _zz_memory   = 0;
49int   _zz_network  = 0;
50
51/* Library initialisation shit */
52void _zz_init(void)
53{
54    char *tmp, *tmp2;
55
56    _zz_load_mem();
57    _zz_load_signal();
58    _zz_load_fd();
59    _zz_load_stream();
60
61    tmp = getenv("ZZUF_DEBUG");
62    if(tmp && *tmp == '1')
63        _zz_hasdebug = 1;
64
65    tmp = getenv("ZZUF_SEED");
66    if(tmp && *tmp)
67        _zz_setseed(atol(tmp));
68
69    tmp = getenv("ZZUF_MINRATIO");
70    tmp2 = getenv("ZZUF_MAXRATIO");
71    if(tmp && *tmp && tmp2 && *tmp2)
72        _zz_setratio(atof(tmp), atof(tmp2));
73
74    tmp = getenv("ZZUF_AUTOINC");
75    if(tmp && *tmp == '1')
76        _zz_setautoinc();
77
78    tmp = getenv("ZZUF_PROTECT");
79    if(tmp && *tmp)
80        _zz_protect(tmp);
81
82    tmp = getenv("ZZUF_REFUSE");
83    if(tmp && *tmp)
84        _zz_refuse(tmp);
85
86    tmp = getenv("ZZUF_INCLUDE");
87    if(tmp && *tmp)
88        _zz_include(tmp);
89
90    tmp = getenv("ZZUF_EXCLUDE");
91    if(tmp && *tmp)
92        _zz_exclude(tmp);
93
94    tmp = getenv("ZZUF_SIGNAL");
95    if(tmp && *tmp == '1')
96        _zz_signal = 1;
97
98    tmp = getenv("ZZUF_MEMORY");
99    if(tmp && *tmp == '1')
100        _zz_memory = 1;
101
102    tmp = getenv("ZZUF_NETWORK");
103    if(tmp && *tmp == '1')
104        _zz_network = 1;
105
106    _zz_fd_init();
107
108    tmp = getenv("ZZUF_STDIN");
109    if(tmp && *tmp == '1')
110        _zz_register(0);
111
112    _zz_ready = 1;
113
114    debug("libzzuf initialised for PID %li", (long int)getpid());
115}
116
117/* Deinitialisation */
118void _zz_fini(void)
119{
120    _zz_fd_fini();
121}
122
Note: See TracBrowser for help on using the repository browser.