Skip to content

Commit

Permalink
Disabling heap allocation because longjmp(3) is incompatible with it
Browse files Browse the repository at this point in the history
  • Loading branch information
plusun committed Jun 19, 2018
1 parent 7f7a5fe commit 5813323
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions usr.bin/sed/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,10 @@ jmp_buf fuzzer_exit;
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);

int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
if (Size == 0)
static const size_t N = 1024;
if (Size == 0 || Size > N)
return 0;
char *buffer = (char *)malloc(Size);
char buffer[N];
memcpy(buffer, Data, Size);

size_t i, last = 0;
Expand All @@ -264,20 +265,19 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
finput.buffer = buffer + last;
finput.off = 0;
finput.len = Size - last;
} else
} else {
return 0;
}

outfile = stdout;
outfname = "stdout";
if (setjmp(fuzzer_exit)) {
goto end;
return 0;
} else {
compile();
process();
}

end:
free(buffer);
return 0;
}
#endif
Expand Down

0 comments on commit 5813323

Please sign in to comment.