#include <string.h>
#include <getopt.h>
+extern int LLVMFuzzerInitialize(int *argc, char ***argv);
extern int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size);
extern unsigned int fuzz_minimal_input_size(void);
else if ( optind != (argc - 1) )
goto usage;
+ if ( LLVMFuzzerInitialize(&argc, &argv) )
+ exit(-1);
+
if ( fp != stdin ) /* If not using stdin, open the provided file. */
{
fp = fopen(argv[optind], "rb");
}
}
+int LLVMFuzzerInitialize(int *argc, char ***argv)
+{
+ if ( !emul_test_init() )
+ {
+ printf("Warning: Stack could not be made executable (%d).\n", errno);
+ return 1;
+ }
+
+ return 0;
+}
+
int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)
{
- bool stack_exec;
struct cpu_user_regs regs = {};
struct x86_emulate_ctxt ctxt = {
.regs = ®s,
};
int rc;
- stack_exec = emul_test_init();
- if ( !stack_exec )
- {
- printf("Warning: Stack could not be made executable (%d).\n", errno);
- return 1;
- }
-
/* Reset all global state variables */
memset(&input, 0, sizeof(input));
data_index = 0;