Coverage Report

Created: 2026-12-01 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libfplist/ossfuzz/property_list_fuzzer.cc
Line
Count
Source
1
/*
2
 * OSS-Fuzz target for libfplist property_list type
3
 *
4
 * Copyright (C) 2016-2026, 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
2.81k
{
35
2.81k
  libfplist_property_t *property         = NULL;
36
2.81k
  libfplist_property_list_t *property_list = NULL;
37
38
2.81k
  if( libfplist_property_list_initialize(
39
2.81k
       &property_list,
40
2.81k
       NULL ) != 1 )
41
0
  {
42
0
    return( 0 );
43
0
  }
44
2.81k
  if( libfplist_property_list_copy_from_byte_stream(
45
2.81k
       property_list,
46
2.81k
       data,
47
2.81k
       size,
48
2.81k
       NULL ) == 1 )
49
1.42k
  {
50
1.42k
    libfplist_property_list_has_plist_root_element(
51
1.42k
     property_list,
52
1.42k
     NULL );
53
54
1.42k
    if( libfplist_property_list_get_root_property(
55
1.42k
         property_list,
56
1.42k
         &property,
57
1.42k
         NULL ) == 1 )
58
1.30k
    {
59
      /* Retrieves the root property with a non-NULL property
60
       * to exercise the value already set error branch
61
       */
62
1.30k
      libfplist_property_list_get_root_property(
63
1.30k
       property_list,
64
1.30k
       &property,
65
1.30k
       NULL );
66
1.30k
      libfplist_property_free(
67
1.30k
       &property,
68
1.30k
       NULL );
69
1.30k
    }
70
1.42k
    property = NULL;
71
72
    /* Note that a property list can only be parsed from a byte stream once
73
     * A second copy_from_byte_stream call exercises the
74
     * value already set error branch
75
     */
76
1.42k
    libfplist_property_list_copy_from_byte_stream(
77
1.42k
     property_list,
78
1.42k
     data,
79
1.42k
     size,
80
1.42k
     NULL );
81
1.42k
  }
82
2.81k
  libfplist_property_list_free(
83
2.81k
   &property_list,
84
2.81k
   NULL );
85
86
2.81k
  return( 0 );
87
2.81k
}
88
89
} /* extern "C" */