1/* Simpler gnu89 version of StandaloneFuzzTargetMain.c from LLVM */
2
3#include <assert.h>
4#include <stdio.h>
5#include <stdlib.h>
6
7extern int LLVMFuzzerTestOneInput (const unsigned char *data, size_t size);
8
9int
10main (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 (filename: argv[1], modes: "r");
21 assert (f);
22 fseek (stream: f, off: 0, SEEK_END);
23 tell_result = ftell (stream: f);
24 assert (tell_result >= 0);
25 len = (size_t) tell_result;
26 fseek (stream: f, off: 0, SEEK_SET);
27 buf = (unsigned char*) malloc (size: len);
28 n_read = fread (ptr: buf, size: 1, n: len, stream: f);
29 assert (n_read == len);
30 LLVMFuzzerTestOneInput (data: buf, size: len);
31
32 free (ptr: buf);
33 printf (format: "Done!\n");
34 return 0;
35}
36

source code of gtk/subprojects/glib/fuzzing/driver.c