/src/liblouis/tests/fuzzing/table_fuzzer.cc
Line | Count | Source |
1 | | #include <stdlib.h> |
2 | | #include <stdint.h> |
3 | | #include <stdio.h> |
4 | | #include "../../liblouis/liblouis.h" |
5 | | #include <filesystem> |
6 | | |
7 | | extern "C" int |
8 | | LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) |
9 | 2 | { |
10 | 2 | char new_file[256]; |
11 | 2 | sprintf(new_file, "/tmp/libfuzzer.uti"); |
12 | | |
13 | 2 | FILE *fp = fopen(new_file, "wb"); |
14 | 2 | if (!fp) |
15 | 0 | return 0; |
16 | 2 | fwrite(data, size, 1, fp); |
17 | 2 | fclose(fp); |
18 | | |
19 | 2 | char *table = "empty.ctb"; |
20 | 2 | lou_compileString(table, "include /tmp/libfuzzer.uti"); |
21 | | |
22 | 2 | lou_free(); |
23 | 2 | std::__fs::filesystem::remove_all("/tmp/libfuzzer.uti"); |
24 | | |
25 | 2 | return 0; |
26 | 2 | } |