"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libhfuzz/persistent.c" between
honggfuzz-2.1.tar.gz and honggfuzz-2.2.tar.gz

About: honggfuzz is a security oriented, feedback-driven, evolutionary, easy-to-use fuzzer with powerful analysis options.

persistent.c  (honggfuzz-2.1):persistent.c  (honggfuzz-2.2)
skipping to change at line 23 skipping to change at line 23
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include "honggfuzz.h" #include "honggfuzz.h"
#include "libhfcommon/common.h" #include "libhfcommon/common.h"
#include "libhfcommon/files.h" #include "libhfcommon/files.h"
#include "libhfcommon/log.h" #include "libhfcommon/log.h"
#include "libhfuzz/fetch.h" #include "libhfuzz/fetch.h"
#include "libhfuzz/instrument.h" #include "libhfuzz/instrument.h"
#include "libhfuzz/libhfuzz.h" #include "libhfuzz/libhfuzz.h"
#include "libhfuzz/performance.h"
__attribute__((weak)) int LLVMFuzzerInitialize( __attribute__((weak)) int LLVMFuzzerInitialize(
int* argc HF_ATTR_UNUSED, char*** argv HF_ATTR_UNUSED) { int* argc HF_ATTR_UNUSED, char*** argv HF_ATTR_UNUSED) {
return 1; return 1;
} }
__attribute__((weak)) size_t LLVMFuzzerMutate( __attribute__((weak)) size_t LLVMFuzzerMutate(
uint8_t* Data HF_ATTR_UNUSED, size_t Size HF_ATTR_UNUSED, size_t MaxSize HF_ ATTR_UNUSED) { uint8_t* Data HF_ATTR_UNUSED, size_t Size HF_ATTR_UNUSED, size_t MaxSize HF_ ATTR_UNUSED) {
LOG_F("LLVMFuzzerMutate() is not supported in honggfuzz yet"); LOG_F("LLVMFuzzerMutate() is not supported in honggfuzz yet");
return 0; return 0;
skipping to change at line 60 skipping to change at line 61
PLOG_F("mmap(fd=%d, size=%zu) of the input file failed", _HF_INPUT_FD, PLOG_F("mmap(fd=%d, size=%zu) of the input file failed", _HF_INPUT_FD,
(size_t)_HF_INPUT_MAX_SIZE); (size_t)_HF_INPUT_MAX_SIZE);
} }
} }
void HF_ITER(const uint8_t** buf_ptr, size_t* len_ptr) { void HF_ITER(const uint8_t** buf_ptr, size_t* len_ptr) {
HonggfuzzFetchData(buf_ptr, len_ptr); HonggfuzzFetchData(buf_ptr, len_ptr);
} }
extern const char* const LIBHFUZZ_module_memorycmp; extern const char* const LIBHFUZZ_module_memorycmp;
extern const char* const LIBHFUZZ_module_instrument;
static void HonggfuzzRunOneInput(const uint8_t* buf, size_t len) { static void HonggfuzzRunOneInput(const uint8_t* buf, size_t len) {
instrumentResetLocalCovFeedback();
int ret = LLVMFuzzerTestOneInput(buf, len); int ret = LLVMFuzzerTestOneInput(buf, len);
if (ret != 0) { if (ret != 0) {
LOG_D("Dereferenced: %s", LIBHFUZZ_module_memorycmp); LOG_D("Dereferenced: %s, %s", LIBHFUZZ_module_memorycmp, LIBHFUZZ_module _instrument);
LOG_F("LLVMFuzzerTestOneInput() returned '%d' instead of '0'", ret); LOG_F("LLVMFuzzerTestOneInput() returned '%d' instead of '0'", ret);
} }
instrument8BitCountersCount();
} }
static void HonggfuzzPersistentLoop(void) { static void HonggfuzzPersistentLoop(void) {
for (;;) { for (;;) {
size_t len; size_t len;
const uint8_t* buf; const uint8_t* buf;
/* Check whether the current benchmark is fast enough, or maybe we shoul
d restart it */
performanceCheck();
HonggfuzzFetchData(&buf, &len); HonggfuzzFetchData(&buf, &len);
HonggfuzzRunOneInput(buf, len); HonggfuzzRunOneInput(buf, len);
} }
} }
static int HonggfuzzRunFromFile(int argc, char** argv) { static int HonggfuzzRunFromFile(int argc, char** argv) {
int in_fd = STDIN_FILENO; int in_fd = STDIN_FILENO;
const char* fname = "[STDIN]"; const char* fname = "[STDIN]";
if (argc > 1) { if (argc > 1) {
fname = argv[argc - 1]; fname = argv[argc - 1];
if ((in_fd = TEMP_FAILURE_RETRY(open(argv[argc - 1], O_RDONLY))) == -1) { if ((in_fd = TEMP_FAILURE_RETRY(open(argv[argc - 1], O_RDONLY))) == -1) {
PLOG_W("Cannot open '%s' as input, using stdin", argv[argc - 1]); PLOG_W("Cannot open '%s' as input, using stdin", argv[argc - 1]);
in_fd = STDIN_FILENO; in_fd = STDIN_FILENO;
fname = "[STDIN]"; fname = "[STDIN]";
} }
} }
LOG_I("Accepting input from '%s'", fname); LOG_I("Accepting input from '%s'", fname);
LOG_I("Usage for fuzzing: honggfuzz -P [flags] -- %s", argv[0]); LOG_I("Usage for fuzzing: honggfuzz -P [flags] -- %s", argv[0]);
uint8_t* buf = (uint8_t*)util_Malloc(_HF_INPUT_MAX_SIZE); uint8_t* buf = (uint8_t*)util_Calloc(_HF_INPUT_MAX_SIZE);
ssize_t len = files_readFromFd(in_fd, buf, _HF_INPUT_MAX_SIZE); ssize_t len = files_readFromFd(in_fd, buf, _HF_INPUT_MAX_SIZE);
if (len < 0) { if (len < 0) {
LOG_E("Couldn't read data from stdin: %s", strerror(errno)); LOG_E("Couldn't read data from stdin: %s", strerror(errno));
free(buf); free(buf);
return -1; return -1;
} }
HonggfuzzRunOneInput(buf, len); HonggfuzzRunOneInput(buf, len);
free(buf); free(buf);
return 0; return 0;
 End of changes. 7 change blocks. 
2 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)