/src/libfwsi/ossfuzz/item_fuzzer.cc
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /*  | 
2  |  |  * OSS-Fuzz target for libfwsi item type  | 
3  |  |  *  | 
4  |  |  * Copyright (C) 2010-2024, Joachim Metz <joachim.metz@gmail.com>  | 
5  |  |  *  | 
6  |  |  * Refer to AUTHORS for acknowledgements.  | 
7  |  |  *  | 
8  |  |  * This program is free software: you can redistribute it and/or modify  | 
9  |  |  * it under the terms of the GNU Lesser General Public License as published by  | 
10  |  |  * the Free Software Foundation, either version 3 of the License, or  | 
11  |  |  * (at your option) any later version.  | 
12  |  |  *  | 
13  |  |  * This program is distributed in the hope that it will be useful,  | 
14  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
15  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  | 
16  |  |  * GNU General Public License for more details.  | 
17  |  |  *  | 
18  |  |  * You should have received a copy of the GNU Lesser General Public License  | 
19  |  |  * along with this program.  If not, see <https://www.gnu.org/licenses/>.  | 
20  |  |  */  | 
21  |  |  | 
22  |  | #include <stddef.h>  | 
23  |  | #include <stdint.h>  | 
24  |  |  | 
25  |  | /* Note that some of the OSS-Fuzz engines use C++  | 
26  |  |  */  | 
27  |  | extern "C" { | 
28  |  |  | 
29  |  | #include "ossfuzz_libfwsi.h"  | 
30  |  |  | 
31  |  | int LLVMFuzzerTestOneInput(  | 
32  |  |      const uint8_t *data,  | 
33  |  |      size_t size )  | 
34  | 15.6k  | { | 
35  | 15.6k  |   libfwsi_item_t *item = NULL;  | 
36  |  |  | 
37  | 15.6k  |   if( libfwsi_item_initialize(  | 
38  | 15.6k  |        &item,  | 
39  | 15.6k  |        NULL ) != 1 )  | 
40  | 0  |   { | 
41  | 0  |     return( 0 );  | 
42  | 0  |   }  | 
43  | 15.6k  |   libfwsi_item_copy_from_byte_stream(  | 
44  | 15.6k  |    item,  | 
45  | 15.6k  |    data,  | 
46  | 15.6k  |    size,  | 
47  | 15.6k  |    LIBFWSI_ENDIAN_LITTLE,  | 
48  | 15.6k  |    NULL );  | 
49  |  |  | 
50  | 15.6k  |   libfwsi_item_free(  | 
51  | 15.6k  |    &item,  | 
52  | 15.6k  |    NULL );  | 
53  |  |  | 
54  | 15.6k  |   return( 0 );  | 
55  | 15.6k  | }  | 
56  |  |  | 
57  |  | } /* extern "C" */  | 
58  |  |  |