about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-12-03 11:35:30 +0100
committervanhauser-thc <vh@thc.org>2021-12-03 11:35:30 +0100
commitfc094dee13060fd84e89764a9526c11a55072e4d (patch)
treeeee935905f19703f7bb1bc9dd48b0deed6fe9e50 /test
parenta915c05740089890ce38a7809d3252116d1f4fb2 (diff)
downloadafl++-fc094dee13060fd84e89764a9526c11a55072e4d.tar.gz
change dlopen solution
Diffstat (limited to 'test')
-rw-r--r--test/test-dlopen.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/test-dlopen.c b/test/test-dlopen.c
index d08d9092..b81bab13 100644
--- a/test/test-dlopen.c
+++ b/test/test-dlopen.c
@@ -5,7 +5,13 @@
 
 int main(int argc, char **argv) {
 
-  if (!getenv("TEST_DLOPEN_TARGET")) return 1;
+  if (!getenv("TEST_DLOPEN_TARGET")) {
+
+    fprintf(stderr, "Error: TEST_DLOPEN_TARGET not set!\n");
+    return 1;
+
+  }
+
   void *lib = dlopen(getenv("TEST_DLOPEN_TARGET"), RTLD_LAZY);
   if (!lib) {
 
@@ -15,8 +21,18 @@ int main(int argc, char **argv) {
   }
 
   int (*func)(int, char **) = dlsym(lib, "main_exported");
-  if (!func) return 3;
+  if (!func) {
+
+    fprintf(stderr, "Error: main_exported not found!\n");
+    return 3;
+
+  }
+
+  // must use deferred forkserver as otherwise afl++ instrumentation aborts
+  // because all dlopen() of instrumented libs must be before the forkserver
+  __AFL_INIT();
 
+  fprintf(stderr, "Running main_exported\n");
   return func(argc, argv);
 
 }