Add a second level of debugging for slightly less useful information.
This commit is contained in:
parent
6b8b80e24d
commit
906ef22f84
@ -1,4 +1,4 @@
|
||||
.TH libzzuf 3 "2008-06-10" "libzzuf"
|
||||
.TH libzzuf 3 "2009-11-22" "libzzuf"
|
||||
.SH NAME
|
||||
libzzuf \- helper library for the zzuf multiple purpose fuzzer
|
||||
.SH DESCRIPTION
|
||||
@ -20,6 +20,12 @@ they are read, no further information can be sent to the fuzzed process.
|
||||
All environment variables are optional.
|
||||
.TP
|
||||
\fBZZUF_DEBUG\fR
|
||||
This environment variable is set to the debugging level. 0 means no debugging
|
||||
information is sent to \fBzzuf\fR. 1 logs important information as well as
|
||||
all diverted functions. 2 logs fuzzing status and all optional file stream
|
||||
information.
|
||||
.TP
|
||||
\fBZZUF_DEBUGFD\fR
|
||||
This environment variable is set to a file descriptor where \fBlibzzuf\fR will
|
||||
send debugging information. This is used to send data to the main \fBzzuf\fR
|
||||
controlling binary.
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
.TH zzuf 1 "2006-12-22" "zzuf"
|
||||
.TH zzuf 1 "2009-11-22" "zzuf"
|
||||
.SH NAME
|
||||
zzuf \- multiple purpose fuzzer
|
||||
.SH SYNOPSIS
|
||||
@ -92,7 +92,8 @@ This option is only relevant if the \fB\-s\fR flag is used with a range
|
||||
argument.
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-debug\fR
|
||||
Activate the display of debug messages.
|
||||
Activate the display of debug messages. Can be specified multiple times for
|
||||
increased verbosity.
|
||||
.TP
|
||||
\fB\-D\fR, \fB\-\-delay\fR=\fIdelay\fR
|
||||
Do not launch more than one process every \fIdelay\fR seconds. This option
|
||||
|
||||
27
src/debug.c
27
src/debug.c
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* zzuf - general purpose fuzzer
|
||||
* Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
|
||||
* Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* $Id$
|
||||
@ -36,7 +36,7 @@
|
||||
#include "debug.h"
|
||||
#include "libzzuf.h"
|
||||
|
||||
extern int _zz_debugfd;
|
||||
static void mydebug(char const *format, va_list args);
|
||||
|
||||
/**
|
||||
* Helper macro to write an integer value to a given file descriptor,
|
||||
@ -56,6 +56,24 @@ extern int _zz_debugfd;
|
||||
write(fd, b + 1, (int)(buf + 127 - b)); \
|
||||
} while(0)
|
||||
|
||||
void _zz_debug(char const *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
if (_zz_debuglevel >= 1)
|
||||
mydebug(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void _zz_debug2(char const *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
if (_zz_debuglevel >= 2)
|
||||
mydebug(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a string, printf-like, and write the resulting data to zzuf's
|
||||
* debug file descriptor _zz_debugfd. If the debug file descriptor is
|
||||
@ -67,18 +85,16 @@ extern int _zz_debugfd;
|
||||
* - vfprintf(stderr, format, args);
|
||||
* - fprintf(stderr, "\n");
|
||||
*/
|
||||
void _zz_debug(char const *format, ...)
|
||||
static void mydebug(char const *format, va_list args)
|
||||
{
|
||||
static char const *hex2char = "0123456789abcdef";
|
||||
char const *f;
|
||||
va_list args;
|
||||
int saved_errno;
|
||||
|
||||
if(_zz_debugfd < 0)
|
||||
return;
|
||||
|
||||
saved_errno = errno;
|
||||
va_start(args, format);
|
||||
|
||||
write(_zz_debugfd, "** zzuf debug ** ", 17);
|
||||
for(f = format; *f; f++)
|
||||
@ -186,6 +202,5 @@ void _zz_debug(char const *format, ...)
|
||||
}
|
||||
}
|
||||
write(_zz_debugfd, "\n", 1);
|
||||
va_end(args);
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* zzuf - general purpose fuzzer
|
||||
* Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
|
||||
* Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* $Id$
|
||||
@ -17,10 +17,13 @@
|
||||
*/
|
||||
|
||||
extern void _zz_debug(const char *format, ...) ATTRIBUTE_PRINTF(1,2);
|
||||
extern void _zz_debug2(const char *format, ...) ATTRIBUTE_PRINTF(1,2);
|
||||
|
||||
#ifdef LIBZZUF
|
||||
# define debug _zz_debug
|
||||
# define debug2 _zz_debug2
|
||||
#else
|
||||
# define debug(...)
|
||||
# define debug(...) do {} while(0)
|
||||
# define debug2(...) do {} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
6
src/fd.c
6
src/fd.c
@ -223,10 +223,8 @@ void _zz_register(int fd)
|
||||
if(fd < 0 || fd > 65535 || (fd < maxfd && fds[fd] != -1))
|
||||
return;
|
||||
|
||||
#if 0
|
||||
if(autoinc)
|
||||
debug("using seed %li", (long int)seed);
|
||||
#endif
|
||||
debug2("using seed %li", (long int)seed);
|
||||
|
||||
/* If filedescriptor is outside our bounds */
|
||||
while(fd >= maxfd)
|
||||
@ -377,6 +375,8 @@ void _zz_setfuzzed(int fd, int count)
|
||||
&& count <= files[fds[fd]].already_fuzzed)
|
||||
return;
|
||||
|
||||
debug2("setfuzzed(%i, %i)", fd, count);
|
||||
|
||||
files[fds[fd]].already_pos = files[fds[fd]].pos;
|
||||
files[fds[fd]].already_fuzzed = count;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* zzuf - general purpose fuzzer
|
||||
* Copyright (c) 2006-2007 Sam Hocevar <sam@zoy.org>
|
||||
* Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* $Id$
|
||||
@ -91,7 +91,7 @@ void _zz_fuzz(int fd, volatile uint8_t *buf, int64_t len)
|
||||
int64_t i, j;
|
||||
int todo;
|
||||
|
||||
debug("fuzz(%i, @%lli, %lli)", fd, (long long int)pos, (long long int)len);
|
||||
debug2("fuzz(%i, @%lli, %lli)", fd, (long long int)pos, (long long int)len);
|
||||
|
||||
aligned_buf = buf - pos;
|
||||
fuzz = _zz_getfuzz(fd);
|
||||
|
||||
@ -64,14 +64,21 @@ BOOL WINAPI DllMain(HINSTANCE, DWORD, PVOID);
|
||||
/**
|
||||
* Is libzzuf fully initialised?
|
||||
*/
|
||||
int _zz_ready = 0;
|
||||
int _zz_ready = 0;
|
||||
|
||||
/**
|
||||
* The debugging level that libzzuf should use. 0 means no debugging,
|
||||
* 1 means minimal debugging, 2 means verbose debugging. Its value is set
|
||||
* by the ZZUF_DEBUG environment variable.
|
||||
*/
|
||||
int _zz_debuglevel = 0;
|
||||
|
||||
/**
|
||||
* The file descriptor used by libzzuf for communication with the main
|
||||
* zzuf program in debug mode. Its value is set by the ZZUF_DEBUG
|
||||
* zzuf program in debug mode. Its value is set by the ZZUF_DEBUGFD
|
||||
* environment variable.
|
||||
*/
|
||||
int _zz_debugfd = -1;
|
||||
int _zz_debugfd = -1;
|
||||
|
||||
/**
|
||||
* If set to 1, this boolean variable will prevent the called application
|
||||
@ -79,7 +86,7 @@ int _zz_debugfd = -1;
|
||||
* SDL applications often do that when not using SDL_INIT_NOPARACHUTE, for
|
||||
* instance. Its value is set by the ZZUF_SIGNAL environment variable.
|
||||
*/
|
||||
int _zz_signal = 0;
|
||||
int _zz_signal = 0;
|
||||
|
||||
/**
|
||||
* If set to a positive value, this value will indicate the maximum number
|
||||
@ -87,14 +94,14 @@ int _zz_signal = 0;
|
||||
* allowed to allocate. Its value is set by the ZZUF_MEMORY environment
|
||||
* variable.
|
||||
*/
|
||||
int _zz_memory = 0;
|
||||
int _zz_memory = 0;
|
||||
|
||||
/**
|
||||
* If set to 1, this boolean will tell libzzuf to fuzz network file
|
||||
* descriptors, too. Its value is set by the ZZUF_NETWORK environment
|
||||
* variable.
|
||||
*/
|
||||
int _zz_network = 0;
|
||||
int _zz_network = 0;
|
||||
|
||||
/**
|
||||
* Library initialisation routine.
|
||||
@ -110,6 +117,10 @@ void _zz_init(void)
|
||||
char *tmp, *tmp2;
|
||||
|
||||
tmp = getenv("ZZUF_DEBUG");
|
||||
if(tmp)
|
||||
_zz_debuglevel = atoi(tmp);
|
||||
|
||||
tmp = getenv("ZZUF_DEBUGFD");
|
||||
if(tmp)
|
||||
_zz_debugfd = atoi(tmp);
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* zzuf - general purpose fuzzer
|
||||
* Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
|
||||
* Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
|
||||
* All Rights Reserved
|
||||
*
|
||||
* $Id$
|
||||
@ -50,6 +50,7 @@ struct fuzz
|
||||
/* Internal variables */
|
||||
extern int _zz_ready;
|
||||
extern int _zz_disabled;
|
||||
extern int _zz_debuglevel;
|
||||
extern int _zz_debugfd;
|
||||
extern int _zz_signal;
|
||||
extern int _zz_memory;
|
||||
|
||||
@ -157,7 +157,7 @@ int main(int argc, char *argv[])
|
||||
char *include = NULL, *exclude = NULL;
|
||||
int cmdline = 0;
|
||||
#endif
|
||||
int network = 0;
|
||||
int debug = 0, network = 0;
|
||||
int i;
|
||||
|
||||
_zz_opts_init(opts);
|
||||
@ -259,7 +259,7 @@ int main(int argc, char *argv[])
|
||||
opts->maxcrashes = 0;
|
||||
break;
|
||||
case 'd': /* --debug */
|
||||
setenv("ZZUF_DEBUG", DEBUG_FILENO_STR, 1);
|
||||
debug++;
|
||||
break;
|
||||
case 'D': /* --delay */
|
||||
if(myoptarg[0] == '=')
|
||||
@ -467,6 +467,9 @@ int main(int argc, char *argv[])
|
||||
setenv("ZZUF_EXCLUDE", exclude, 1);
|
||||
#endif
|
||||
|
||||
setenv("ZZUF_DEBUG", debug ? debug > 1 ? "2" : "1" : "0", 1);
|
||||
setenv("ZZUF_DEBUGFD", DEBUG_FILENO_STR, 1);
|
||||
|
||||
if(opts->fuzzing)
|
||||
setenv("ZZUF_FUZZING", opts->fuzzing, 1);
|
||||
if(opts->bytes)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user