/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  | 6.61k  | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | 
32  | 6.61k  |   CrcGenerateTable();  | 
33  | 6.61k  |   Crc64GenerateTable();  | 
34  |  |  | 
35  | 6.61k  |   CXzDecMtProps props;  | 
36  | 6.61k  |   XzDecMtProps_Init(&props);  | 
37  |  |  | 
38  | 6.61k  |   OutputBuffer out_buffer;  | 
39  | 6.61k  |   InputBuffer in_buffer(data, size);  | 
40  | 6.61k  |   CXzStatInfo stats;  | 
41  | 6.61k  |   int isMt;  | 
42  |  |  | 
43  | 6.61k  |   CXzDecMtHandle handle = XzDecMt_Create(&CommonAlloc, &CommonAlloc);  | 
44  | 6.61k  |   XzDecMt_Decode(handle, &props, nullptr, 1, out_buffer.stream(),  | 
45  | 6.61k  |       in_buffer.stream(), &stats, &isMt, nullptr);  | 
46  | 6.61k  |   XzDecMt_Destroy(handle);  | 
47  | 6.61k  |   return 0;  | 
48  | 6.61k  | }  |