/src/clib/test/fuzzing/fuzz_manifest.c
Line | Count | Source (jump to first uncovered line) |
1 | | #include <stdio.h> |
2 | | #include <stdlib.h> |
3 | | #include <string.h> |
4 | | #include <stdint.h> |
5 | | #include <unistd.h> |
6 | | #include "../../src/common/clib-package.h" |
7 | | |
8 | 12 | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
9 | 12 | if(size<3){ |
10 | 0 | return 0; |
11 | 0 | } |
12 | 12 | char filename[256]; |
13 | 12 | sprintf(filename, "libfuzzer.json"); |
14 | | |
15 | 12 | FILE *fp = fopen(filename, "wb"); |
16 | 12 | if (!fp) |
17 | 0 | return 0; |
18 | 12 | fwrite(data, size, 1, fp); |
19 | 12 | fclose(fp); |
20 | | |
21 | 12 | clib_package_t *pkg = |
22 | 12 | clib_package_load_from_manifest(filename, 0); |
23 | 12 | if(pkg) { |
24 | 5 | clib_package_free(pkg); |
25 | 5 | } |
26 | 12 | unlink(filename); |
27 | 12 | return 0; |
28 | 12 | } |