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

Last change on this file since 1679 was 1679, checked in by Sam Hocevar, 16 years ago
  • Got rid of the *_load() functions. Now each diverted function is supposed to check that the *_orig() functions it calls are properly loaded.
  • Property svn:keywords set to Id
File size: 2.4 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 1679 2007-01-16 14:36:33Z 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 "fd.h"
40#include "fuzz.h"
41
42/* Global variables */
43int   _zz_ready    = 0;
44int   _zz_disabled = 0;
45int   _zz_hasdebug = 0;
46int   _zz_signal   = 0;
47int   _zz_memory   = 0;
48int   _zz_network  = 0;
49
50/* Library initialisation shit */
51void _zz_init(void)
52{
53    char *tmp, *tmp2;
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_MINRATIO");
64    tmp2 = getenv("ZZUF_MAXRATIO");
65    if(tmp && *tmp && tmp2 && *tmp2)
66        _zz_setratio(atof(tmp), atof(tmp2));
67
68    tmp = getenv("ZZUF_AUTOINC");
69    if(tmp && *tmp == '1')
70        _zz_setautoinc();
71
72    tmp = getenv("ZZUF_PROTECT");
73    if(tmp && *tmp)
74        _zz_protect(tmp);
75
76    tmp = getenv("ZZUF_REFUSE");
77    if(tmp && *tmp)
78        _zz_refuse(tmp);
79
80    tmp = getenv("ZZUF_INCLUDE");
81    if(tmp && *tmp)
82        _zz_include(tmp);
83
84    tmp = getenv("ZZUF_EXCLUDE");
85    if(tmp && *tmp)
86        _zz_exclude(tmp);
87
88    tmp = getenv("ZZUF_SIGNAL");
89    if(tmp && *tmp == '1')
90        _zz_signal = 1;
91
92    tmp = getenv("ZZUF_MEMORY");
93    if(tmp && *tmp == '1')
94        _zz_memory = 1;
95
96    tmp = getenv("ZZUF_NETWORK");
97    if(tmp && *tmp == '1')
98        _zz_network = 1;
99
100    _zz_fd_init();
101
102    tmp = getenv("ZZUF_STDIN");
103    if(tmp && *tmp == '1')
104        _zz_register(0);
105
106    _zz_ready = 1;
107
108    debug("libzzuf initialised for PID %li", (long int)getpid());
109}
110
111/* Deinitialisation */
112void _zz_fini(void)
113{
114    _zz_fd_fini();
115}
116
Note: See TracBrowser for help on using the repository browser.