From 990f6b3d69373e9979345095d2769f228563ff83 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 15 Dec 2019 14:07:56 +0100 Subject: [PATCH] :art: Add afl-clang-fast special build --- src/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main.c b/src/main.c index 0108e477..7ddc27d3 100644 --- a/src/main.c +++ b/src/main.c @@ -15,6 +15,30 @@ static void sig(int unused NUSED) { #endif } +#ifdef __AFL_HAVE_MANUAL_CONTROL + +ANN static void gwion_reset(const Gwion gwion) { + release_ctx(gwion->env->scope, gwion); + pop_global(gwion); + push_global(gwion, "[user]"); +} + +#define BUFSIZE 1024 + +static void afl_run(const Gwion gwion) { + char buf[BUFSIZE]; + __AFL_INIT(); + while (__AFL_LOOP(1000)) { + memset(buf, 0, BUFSIZE); + read(0, buf, BUFSIZE); + if(compile_string(gwion, "afl", buf)) + gwion_run(gwion); + gwion_reset(gwion); + } +} +#define gwion_run(a) afl_run(a) +#endif + int main(int argc, char** argv) { Arg arg = { .arg={.argc=argc, .argv=argv}, .loop=-1 }; signal(SIGINT, sig); -- 2.43.0