From d8605a54c1dd0112ebfbe4f94186706fa923a88c Mon Sep 17 00:00:00 2001
From: Anh <zenpoems@gmail.com>
Date: Sun, 16 Sep 2018 13:02:16 -0400
Subject: [PATCH] Use C instead of C++

---
 bin/zafl.sh                            |  2 +-
 libzafl/src/SConscript                 |  8 ++++----
 libzafl/src/{libzafl.cpp => libzafl.c} | 20 ++++++++++----------
 3 files changed, 15 insertions(+), 15 deletions(-)
 rename libzafl/src/{libzafl.cpp => libzafl.c} (87%)

diff --git a/bin/zafl.sh b/bin/zafl.sh
index 5e34228..a5d157d 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 9d5253d..823f009 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 d0ff01f..6bb763b 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);
-- 
GitLab