1 #include <assert.h> 2 #include <stdint.h> 3 #include <stdio.h> 4 #include <stdlib.h> 5 6 extern int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size); 7 8 #define INPUT_SIZE 4096 9 static uint8_t input[INPUT_SIZE]; 10 main(int argc,char ** argv)11int main(int argc, char **argv) 12 { 13 size_t size; 14 FILE *fp; 15 16 setbuf(stdout, NULL); 17 18 if ( argc != 2 ) 19 { 20 printf("Expecting only one argument\n"); 21 exit(-1); 22 } 23 24 fp = fopen(argv[1], "rb"); 25 if ( fp == NULL ) 26 { 27 perror("fopen"); 28 exit(-1); 29 } 30 31 size = fread(input, 1, INPUT_SIZE, fp); 32 33 if ( ferror(fp) ) 34 { 35 perror("fread"); 36 exit(-1); 37 } 38 39 if ( !feof(fp) ) 40 { 41 printf("Input too large\n"); 42 exit(-1); 43 } 44 45 fclose(fp); 46 47 return LLVMFuzzerTestOneInput(input, size); 48 } 49 50 /* 51 * Local variables: 52 * mode: C 53 * c-file-style: "BSD" 54 * c-basic-offset: 4 55 * indent-tabs-mode: nil 56 * End: 57 */ 58