fuzz/x86_emulate: clear errors after each iteration

Once feof() returns true for a stream, it will continue to return true
for that stream until clearerr() is called (or the stream is closed
and re-opened).

In llvm-clang-fast-mode, the same file descriptor is used for each
iteration of the loop, meaning that the "Input too large" check was
broken -- feof() would return true even if the fread() hadn't hit the
end of the file.  The result is that AFL generates testcases of
arbitrary size.

Fix this by clearing the error after each iteration.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
George Dunlap authored and Jan Beulich committed 2017-10-09 16:04:11 +02:00
1 parent 581c3e874c
commit 849a1f10c9
1 file changed
+2
@@ -97,6 +97,8 @@ int main(int argc, char **argv)
fclose(fp);
fp = NULL;
}
else
clearerr(fp);
LLVMFuzzerTestOneInput(input, size);
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.