/src/lzma-fuzz/xzdec_fuzzer.cc
Line | Count | Source |
1 | | /** |
2 | | * |
3 | | * @copyright Copyright (c) 2019 Joachim Bauch <mail@joachim-bauch.de> |
4 | | * |
5 | | * @license GNU GPL version 3 or any later version |
6 | | * |
7 | | * This program is free software: you can redistribute it and/or modify |
8 | | * it under the terms of the GNU General Public License as published by |
9 | | * the Free Software Foundation, either version 3 of the License, or |
10 | | * (at your option) any later version. |
11 | | * |
12 | | * This program is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | * GNU General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU General Public License |
18 | | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
19 | | * |
20 | | */ |
21 | | |
22 | | #include <stdint.h> |
23 | | |
24 | | #include "7zCrc.h" |
25 | | #include "Xz.h" |
26 | | #include "XzCrc64.h" |
27 | | |
28 | | #include "common-alloc.h" |
29 | | #include "common-buffer.h" |
30 | | |
31 | 7.24k | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
32 | 7.24k | CrcGenerateTable(); |
33 | 7.24k | Crc64GenerateTable(); |
34 | | |
35 | 7.24k | CXzDecMtProps props; |
36 | 7.24k | XzDecMtProps_Init(&props); |
37 | | |
38 | 7.24k | OutputBuffer out_buffer; |
39 | 7.24k | InputBuffer in_buffer(data, size); |
40 | 7.24k | CXzStatInfo stats; |
41 | 7.24k | int isMt; |
42 | | |
43 | 7.24k | CXzDecMtHandle handle = XzDecMt_Create(&CommonAlloc, &CommonAlloc); |
44 | 7.24k | XzDecMt_Decode(handle, &props, nullptr, 1, out_buffer.stream(), |
45 | 7.24k | in_buffer.stream(), &stats, &isMt, nullptr); |
46 | 7.24k | XzDecMt_Destroy(handle); |
47 | 7.24k | return 0; |
48 | 7.24k | } |