Commit 420989e0 authored by Anh Nguyen-Tuong's avatar Anh Nguyen-Tuong

Insure afl sees instrumentation on first input

parent 3cc41bdc
......@@ -332,6 +332,7 @@ static void zafl_setupAflTracemapSharedMemory()
void zafl_initAflForkServer()
{
int fork_count = 0;
if (getenv("ZAFL_DEBUG")) debug = 1;
PRINT_DEBUG("libautozafl: auto-initialize fork server\n");
......@@ -347,10 +348,6 @@ void zafl_initAflForkServer()
zafl_trace_map = (u8*)malloc(MAP_SIZE);
}
// force map entry to get past afl sanity checks
if (debug)
zafl_trace_map[MAP_SIZE-1] = 1;
int n = write(FORKSRV_FD+1, &__afl_temp_data,4);
if(n != 4)
{
......@@ -369,6 +366,19 @@ void zafl_initAflForkServer()
return;
}
// force map entry to get past afl sanity check for instrumentation
if (fork_count == 0)
{
zafl_trace_map[MAP_SIZE-1]++;
fork_count++;
}
else if (fork_count == 1)
{
// on 2nd fork, restore correct value
zafl_trace_map[MAP_SIZE-1]--;
fork_count++;
}
__afl_fork_pid = fork();
if(__afl_fork_pid < 0)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment