Move fuzz-emul.c function prototypes into a header. Also share the
definition of the input size (rather than hard-coding it in
fuzz-emul.c).
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
+#include "fuzz-emul.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);
-
-#define INPUT_SIZE 4096
static uint8_t input[INPUT_SIZE];
int main(int argc, char **argv)
#include <xen/xen.h>
#include "x86-emulate.h"
+#include "fuzz-emul.h"
#define MSR_INDEX_MAX 16
struct cpu_user_regs regs;
struct segment_register segments[SEG_NUM];
unsigned long options;
- unsigned char data[4096];
+ unsigned char data[INPUT_SIZE];
} input;
#define DATA_OFFSET offsetof(struct fuzz_corpus, data)
return 1;
}
- if ( size > sizeof(input) )
+ if ( size > INPUT_SIZE )
{
printf("Input too large\n");
return 1;
unsigned int fuzz_minimal_input_size(void)
{
+ BUILD_BUG_ON(DATA_OFFSET > INPUT_SIZE);
+
return DATA_OFFSET + 1;
}
--- /dev/null
+#ifndef FUZZ_EMUL_H
+# define FUZZ_EMUL_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);
+
+#define INPUT_SIZE 4096
+
+#endif /* ifdef FUZZ_EMUL_H */