/src/clib/test/fuzzing/fuzz_manifest.c
Line | Count | Source |
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 | 1.99k | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
9 | 1.99k | if(size<3){ |
10 | 2 | return 0; |
11 | 2 | } |
12 | 1.99k | char filename[256]; |
13 | 1.99k | sprintf(filename, "libfuzzer.json"); |
14 | | |
15 | 1.99k | FILE *fp = fopen(filename, "wb"); |
16 | 1.99k | if (!fp) |
17 | 0 | return 0; |
18 | 1.99k | fwrite(data, size, 1, fp); |
19 | 1.99k | fclose(fp); |
20 | | |
21 | 1.99k | clib_package_t *pkg = |
22 | 1.99k | clib_package_load_from_manifest(filename, 0); |
23 | 1.99k | if(pkg) { |
24 | 721 | clib_package_free(pkg); |
25 | 721 | } |
26 | 1.99k | unlink(filename); |
27 | 1.99k | return 0; |
28 | 1.99k | } |