Commit
849a1f10c9 was checked in inappropriately; review flagged up
that clearerr() was too big a hammer, as it would clear both the EOF
flag and stream errors.
Stream errors shouldn't be cleared; we only want the EOF and other
stream-related state reset. To do this, it is sufficient to fseek()
to zero.
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
exit(-1);
}
}
+#ifdef __AFL_HAVE_MANUAL_CONTROL
+ else
+ {
+ /*
+ * This will ensure we're dealing with a clean stream
+ * state after the afl-fuzz process messes with the open
+ * file handle.
+ */
+ fseek(fp, 0, SEEK_SET);
+ }
+#endif
size = fread(input, 1, INPUT_SIZE, fp);
fclose(fp);
fp = NULL;
}
- else
- clearerr(fp);
LLVMFuzzerTestOneInput(input, size);
}