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

Last change on this file since 1614 was 1614, checked in by Sam Hocevar, 14 years ago
  • Merged chars.c and fuzz.c.
  • Property svn:keywords set to Id
File size: 2.3 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 1614 2007-01-07 18:34:50Z 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 <unistd.h>
29#include <stdlib.h>
30#include <string.h>
31#include <fcntl.h>
32#include <regex.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_network  = 0;
49
50/* Library initialisation shit */
51void _zz_init(void)
52{
53    char *tmp;
54
55    tmp = getenv("ZZUF_DEBUG");
56    if(tmp && *tmp == '1')
57        _zz_hasdebug = 1;
58
59    tmp = getenv("ZZUF_SEED");
60    if(tmp && *tmp)
61        _zz_setseed(atol(tmp));
62
63    tmp = getenv("ZZUF_RATIO");
64    if(tmp && *tmp)
65        _zz_setratio(atof(tmp));
66
67    tmp = getenv("ZZUF_PROTECT");
68    if(tmp && *tmp)
69        _zz_protect(tmp);
70
71    tmp = getenv("ZZUF_REFUSE");
72    if(tmp && *tmp)
73        _zz_refuse(tmp);
74
75    tmp = getenv("ZZUF_INCLUDE");
76    if(tmp && *tmp)
77    {
78        re_include = malloc(sizeof(*re_include));
79        regcomp(re_include, tmp, REG_EXTENDED);
80    }
81
82    tmp = getenv("ZZUF_EXCLUDE");
83    if(tmp && *tmp)
84    {
85        re_exclude = malloc(sizeof(*re_exclude));
86        regcomp(re_exclude, tmp, REG_EXTENDED);
87    }
88
89    tmp = getenv("ZZUF_SIGNAL");
90    if(tmp && *tmp == '1')
91        _zz_signal = 1;
92
93    tmp = getenv("ZZUF_NETWORK");
94    if(tmp && *tmp == '1')
95        _zz_network = 1;
96
97    _zz_fd_init();
98
99    tmp = getenv("ZZUF_STDIN");
100    if(tmp && *tmp == '1')
101        _zz_register(0);
102
103    _zz_load_fd();
104    _zz_load_signal();
105    _zz_load_stream();
106
107    _zz_ready = 1;
108
109    debug("libzzuf initialised");
110}
111
112/* Deinitialisation */
113void _zz_fini(void)
114{
115    _zz_fd_fini();
116}
117
Note: See TracBrowser for help on using the repository browser.