/src/libfplist/ossfuzz/property_fuzzer.cc
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * OSS-Fuzz target for libfplist property type |
3 | | * |
4 | | * Copyright (C) 2016-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_libfplist.h" |
30 | | |
31 | | int LLVMFuzzerTestOneInput( |
32 | | const uint8_t *data, |
33 | | size_t size ) |
34 | 829 | { |
35 | 829 | libfplist_property_t *root_property = NULL; |
36 | 829 | libfplist_property_list_t *property_list = NULL; |
37 | 829 | int value_type = 0; |
38 | | |
39 | 829 | if( libfplist_property_list_initialize( |
40 | 829 | &property_list, |
41 | 829 | NULL ) != 1 ) |
42 | 0 | { |
43 | 0 | return( 0 ); |
44 | 0 | } |
45 | 829 | if( libfplist_property_list_copy_from_byte_stream( |
46 | 829 | property_list, |
47 | 829 | data, |
48 | 829 | size, |
49 | 829 | NULL ) != 1 ) |
50 | 723 | { |
51 | 723 | goto on_error_libfplist_property_list; |
52 | 723 | } |
53 | 106 | if( libfplist_property_list_get_root_property( |
54 | 106 | property_list, |
55 | 106 | &root_property, |
56 | 106 | NULL ) == 1 ) |
57 | 36 | { |
58 | 36 | libfplist_property_get_value_type( |
59 | 36 | root_property, |
60 | 36 | &value_type, |
61 | 36 | NULL ); |
62 | | |
63 | 36 | libfplist_property_free( |
64 | 36 | &root_property, |
65 | 36 | NULL ); |
66 | 36 | } |
67 | 829 | on_error_libfplist_property_list: |
68 | 829 | libfplist_property_list_free( |
69 | 829 | &property_list, |
70 | 829 | NULL ); |
71 | | |
72 | 829 | return( 0 ); |
73 | 106 | } |
74 | | |
75 | | } /* extern "C" */ |
76 | | |