Last change
on this file since 92405 was 91612, checked in by vboxsync, 3 years ago |
src/libs: Export libtpms-0.9.0, bugref:10078
|
File size:
1.1 KB
|
Line | |
---|
1 | #include <stdlib.h>
|
---|
2 | #include <stdio.h>
|
---|
3 |
|
---|
4 | #define MIN_NUMBER_OF_RUNS 4
|
---|
5 | #define EXIT_TEST_SKIP 77
|
---|
6 |
|
---|
7 | extern int LLVMFuzzerTestOneInput (const unsigned char *data, size_t size);
|
---|
8 |
|
---|
9 | int main(int argc, char **argv)
|
---|
10 | {
|
---|
11 | int i, j;
|
---|
12 |
|
---|
13 | for (i = 1; i < argc; i++) {
|
---|
14 | char *name = argv[i];
|
---|
15 | ssize_t size;
|
---|
16 | FILE *f = fopen(name, "rb");
|
---|
17 | char *buf;
|
---|
18 |
|
---|
19 | fprintf(stdout, "%s...\n", name);
|
---|
20 | if (f == NULL) {
|
---|
21 | perror("fopen() failed");
|
---|
22 | continue;
|
---|
23 | }
|
---|
24 | fseek(f, 0, SEEK_END);
|
---|
25 | size = ftell(f);
|
---|
26 | if (size < 0) {
|
---|
27 | fclose(f);
|
---|
28 | perror("ftell() failed");
|
---|
29 | continue;
|
---|
30 | }
|
---|
31 | fseek(f, 0, SEEK_SET);
|
---|
32 | buf = malloc(size + 1);
|
---|
33 | if (fread(buf, 1, size, f) != (size_t)size) {
|
---|
34 | fclose(f);
|
---|
35 | perror("fread() failed");
|
---|
36 | continue;
|
---|
37 | }
|
---|
38 | fclose(f);
|
---|
39 | buf[size] = 0;
|
---|
40 |
|
---|
41 | for (j = 0; j < MIN_NUMBER_OF_RUNS; j++) {
|
---|
42 | if (LLVMFuzzerTestOneInput((void *)buf, size) == EXIT_TEST_SKIP) {
|
---|
43 | return EXIT_TEST_SKIP;
|
---|
44 | }
|
---|
45 | }
|
---|
46 | free(buf);
|
---|
47 | }
|
---|
48 |
|
---|
49 | return EXIT_SUCCESS;
|
---|
50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.