• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Simpler gnu89 version of StandaloneFuzzTargetMain.c from LLVM */
2 
3 #include <assert.h>
4 #include <stdio.h>
5 #include <stdlib.h>
6 
7 extern int LLVMFuzzerTestOneInput (const unsigned char *data, size_t size);
8 
9 int
main(int argc,char ** argv)10 main (int argc, char **argv)
11 {
12   FILE *f;
13   long tell_result;
14   size_t n_read, len;
15   unsigned char *buf;
16 
17   if (argc < 2)
18     return 1;
19 
20   f = fopen (argv[1], "r");
21   assert (f);
22   fseek (f, 0, SEEK_END);
23   tell_result = ftell (f);
24   assert (tell_result >= 0);
25   len = (size_t) tell_result;
26   fseek (f, 0, SEEK_SET);
27   buf = (unsigned char*) malloc (len);
28   n_read = fread (buf, 1, len, f);
29   assert (n_read == len);
30   LLVMFuzzerTestOneInput (buf, len);
31 
32   free (buf);
33   printf ("Done!\n");
34   return 0;
35 }
36