code format and debug
MODIFY
examples/aflpp_driver/GNUmakefile
examples/aflpp_driver/GNUmakefile
@@ -18,7 +18,7 @@ libAFLDriver.a: aflpp_driver.o
ar ru libAFLDriver.a aflpp_driver.o
debug:
- $(LLVM_BINDIR)clang++ -D_DEBUG=\"1\" $(FLAGS) -stdlib=libc++ -funroll-loops -std=c++11 -c aflpp_driver.cpp
+ $(LLVM_BINDIR)clang++ -I../../include -D_DEBUG=\"1\" $(FLAGS) -stdlib=libc++ -funroll-loops -std=c++11 -c aflpp_driver.cpp
ar ru libAFLDriver.a aflpp_driver.o

MODIFY
examples/aflpp_driver/aflpp_driver.cpp
examples/aflpp_driver/aflpp_driver.cpp
@@ -54,6 +54,10 @@ If 1, close stdout at startup. If 2 close stderr; if 3 close both.
#include <iostream>
#include <vector>
+#ifdef _DEBUG
+#include "hash.h"
+#endif
+
// Platform detection. Copied from FuzzerInternal.h
#ifdef __linux__
#define LIBFUZZER_LINUX 1
@@ -273,7 +277,7 @@ int main(int argc, char **argv) {
int num_runs = 0;
while (__afl_persistent_loop(N)) {
#ifdef _DEBUG
- fprintf(stderr, "len: %u\n", *__afl_fuzz_len);
+ fprintf(stderr, "CLIENT crc: %08x len: %u\n", hash32(__afl_fuzz_ptr, *__afl_fuzz_len, 0xa5b35705), *__afl_fuzz_len);
#endif
if (*__afl_fuzz_len) {
num_runs++;

MODIFY
src/afl-forkserver.c
src/afl-forkserver.c
@@ -837,8 +837,8 @@ void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len) {
*fsrv->shmem_fuzz_len = len;
memcpy(fsrv->shmem_fuzz, buf, len);
- // printf("test case len: %u [0]:0x%02x\n", *fsrv->shmem_fuzz_len, buf[0]);
- // fflush(stdout);
+ // fprintf(stderr, "FS crc: %08x len: %u\n", hash32(fsrv->shmem_fuzz,
+ // *fsrv->shmem_fuzz_len, 0xa5b35705), *fsrv->shmem_fuzz_len);
} else {

MODIFY
src/afl-fuzz-init.c
src/afl-fuzz-init.c
@@ -213,8 +213,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
n = kstat_data_lookup(k, "ncpus");
ncpus = n->value.i32;
- if (ncpus > sizeof(cpu_used))
- ncpus = sizeof(cpu_used);
+ if (ncpus > sizeof(cpu_used)) ncpus = sizeof(cpu_used);
for (i = 0; i < ncpus; i++) {
@@ -226,8 +225,7 @@ void bind_to_free_cpu(afl_state_t *afl) {
}
- if (cs.cpu_sysinfo.cpu[CPU_IDLE] > 0)
- continue;
+ if (cs.cpu_sysinfo.cpu[CPU_IDLE] > 0) continue;
if (cs.cpu_sysinfo.cpu[CPU_USER] > 0 || cs.cpu_sysinfo.cpu[CPU_KERNEL] > 0)
cpu_used[i] = 1;

MODIFY
src/afl-gotcpu.c
src/afl-gotcpu.c
@@ -204,8 +204,7 @@ int main(int argc, char **argv) {
#endif
#if defined(__sun)
- if (pset_bind(c, P_PID, getpid(), NULL))
- PFATAL("pset_bind failed");
+ if (pset_bind(c, P_PID, getpid(), NULL)) PFATAL("pset_bind failed");
pset_destroy(c);
#endif

code format and debug