diff options
author | vanhauser-thc <vh@thc.org> | 2021-12-03 11:35:30 +0100 |
---|---|---|
committer | vanhauser-thc <vh@thc.org> | 2021-12-03 11:35:30 +0100 |
commit | fc094dee13060fd84e89764a9526c11a55072e4d (patch) | |
tree | eee935905f19703f7bb1bc9dd48b0deed6fe9e50 /test | |
parent | a915c05740089890ce38a7809d3252116d1f4fb2 (diff) | |
download | afl++-fc094dee13060fd84e89764a9526c11a55072e4d.tar.gz |
change dlopen solution
Diffstat (limited to 'test')
-rw-r--r-- | test/test-dlopen.c | 20 |
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); } |