diff --git a/bin/zafl.sh b/bin/zafl.sh index 5e342283fcd2617cf749850ef088e7a8da3bde0c..a5d157d394bf2856123c98da1f55dcb7fc6ee9f7 100755 --- a/bin/zafl.sh +++ b/bin/zafl.sh @@ -27,7 +27,7 @@ if [ "$#" -lt 2 ]; then exit 1 fi -input_binary=$1 +input_binary=$(realpath $1) output_zafl_binary=$2 shift diff --git a/libzafl/src/SConscript b/libzafl/src/SConscript index 9d5253d1a1970374ecdef1308b54905de3cd3f7e..823f0092b2febba4e70908e0cae9933a1edded13 100644 --- a/libzafl/src/SConscript +++ b/libzafl/src/SConscript @@ -5,16 +5,16 @@ myenv=env.Clone() myenv.Replace(SECURITY_TRANSFORMS_HOME=os.environ['SECURITY_TRANSFORMS_HOME']) myenv.Replace(AFL_PATH=os.environ['AFL_PATH']) -files="libzafl.cpp" +files="libzafl.c" -cpppath=''' +cpath=''' $AFL_PATH/ ../include/ ''' -myenv=myenv.Clone(CPPPATH=Split(cpppath)) +myenv=myenv.Clone(CPPPATH=Split(cpath)) -myenv.Append(CXXFLAGS = " -std=c++11 ") +#myenv.Append(CXXFLAGS = " -std=c++11 ") if int(env['autozafl']) == 1: lib=myenv.SharedLibrary("autozafl", Split(files)) diff --git a/libzafl/src/libzafl.cpp b/libzafl/src/libzafl.c similarity index 87% rename from libzafl/src/libzafl.cpp rename to libzafl/src/libzafl.c index d0ff01f8b260fa038440dda1754a15f18f783e9b..6bb763bcf4d579ce3e9743f836132582b1a1d3c6 100644 --- a/libzafl/src/libzafl.cpp +++ b/libzafl/src/libzafl.c @@ -27,7 +27,7 @@ #include <stdio.h> #include <string.h> -#include "libzafl.hpp" +#include "config.h" // externally visible so that Zipr transformations can access directly u8* zafl_trace_map; @@ -36,13 +36,13 @@ unsigned short zafl_prev_id; static s32 shm_id; static int __afl_temp_data; static pid_t __afl_fork_pid; -static auto debug = false; +static int debug = 0; -#define PRINT_ERROR(string) if (debug) {auto x=write(2, string, strlen(string));} -#define PRINT_DEBUG(string) if (debug) {auto x=write(1, string, strlen(string));} +#define PRINT_ERROR(string) if (debug) {int x=write(2, string, strlen(string));} +#define PRINT_DEBUG(string) if (debug) {int x=write(1, string, strlen(string));} static void zafl_setupSharedMemory(); -static bool shared_memory_is_setup = false; +static int shared_memory_is_setup = 0; #ifdef ZAFL_AUTO_INIT_FORK_SERVER void __attribute__((constructor)) zafl_initAflForkServer(); @@ -54,7 +54,7 @@ void __attribute__((constructor)) zafl_setupSharedMemory(); // even if not running under AFL static void zafl_setupSharedMemory() { - if (getenv("ZAFL_DEBUG")) debug = true; + if (getenv("ZAFL_DEBUG")) debug = 1; if (shared_memory_is_setup) return; @@ -78,16 +78,16 @@ static void zafl_setupSharedMemory() return; } PRINT_DEBUG("libzafl: shared memory segment is setup\n"); - shared_memory_is_setup = true; + shared_memory_is_setup = 1; } void zafl_initAflForkServer() { - static auto fork_server_initialized = false; + static int fork_server_initialized = 0; if (fork_server_initialized) return; - if (getenv("ZAFL_DEBUG")) debug = true; + if (getenv("ZAFL_DEBUG")) debug = 1; zafl_setupSharedMemory(); @@ -104,7 +104,7 @@ void zafl_initAflForkServer() return; } - fork_server_initialized = true; + fork_server_initialized = 1; while(1) { n = read(FORKSRV_FD,&__afl_temp_data,4);