about summary refs log tree commit diff
path: root/test/test-dlopen.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-12-09 11:55:36 +0100
committerGitHub <noreply@github.com>2021-12-09 11:55:36 +0100
commit08ca4d54a55fe73e64a994c41a12af61f52e497e (patch)
tree2d0f060cf98afbe80f5bf810fd6b167a5152be81 /test/test-dlopen.c
parent773baf9391ff5f1793deb7968366819e7fa07adc (diff)
parent4c6d94ea5f854071277ed9729de2d4ef7d07cc84 (diff)
downloadafl++-08ca4d54a55fe73e64a994c41a12af61f52e497e.tar.gz
Merge pull request #1101 from AFLplusplus/dev
Dev
Diffstat (limited to 'test/test-dlopen.c')
-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);
 
 }