Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve fuzzer stability in persistent mode #453

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tools/ZydisFuzzShared.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,25 @@
# include <io.h>
#endif

#ifdef ZYAN_POSIX
# include <unistd.h>
#endif

/* ============================================================================================== */
/* Stream reading abstraction */
/* ============================================================================================== */

ZyanUSize ZydisStdinRead(void *ctx, ZyanU8* buf, ZyanUSize max_len)
{
ZYAN_UNUSED(ctx);
#ifdef ZYAN_POSIX
// `fread` does internal buffering that can result in different code paths to be taken every
// time we call it. This is detrimental for fuzzing stability in persistent mode. Use direct
// syscall when possible.
return read(0, buf, max_len);
#else
return fread(buf, 1, max_len, ZYAN_STDIN);
#endif
}

#ifdef ZYDIS_LIBFUZZER
Expand Down
Loading