Coverage Report

Created: 2026-12-01 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libfwnt/ossfuzz/security_descriptor_fuzzer.cc
Line
Count
Source
1
/*
2
 * OSS-Fuzz target for libfwnt security descriptor type
3
 *
4
 * Copyright (C) 2009-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_libfwnt.h"
30
31
/* Retrieves the entries of the access control list
32
 */
33
static void inspect_access_control_list(
34
           libfwnt_access_control_list_t *access_control_list )
35
390
{
36
390
  libfwnt_access_control_entry_t *access_control_entry  = NULL;
37
390
  libfwnt_security_identifier_t *security_identifier = NULL;
38
39
390
  uint8_t type     = 0;
40
390
  uint8_t flags    = 0;
41
390
  uint32_t access_mask = 0;
42
43
390
  int number_of_entries = 0;
44
390
  int entry_index       = 0;
45
46
390
  if( access_control_list == NULL )
47
0
  {
48
0
    return;
49
0
  }
50
390
  libfwnt_access_control_list_get_number_of_entries(
51
390
   access_control_list,
52
390
   &number_of_entries,
53
390
   NULL );
54
55
390
  for( entry_index = 0;
56
143k
       entry_index < number_of_entries;
57
143k
       entry_index++ )
58
143k
  {
59
143k
    access_control_entry = NULL;
60
61
143k
    if( libfwnt_access_control_list_get_entry_by_index(
62
143k
         access_control_list,
63
143k
         entry_index,
64
143k
         &access_control_entry,
65
143k
         NULL ) != 1 )
66
0
    {
67
0
      break;
68
0
    }
69
143k
    if( access_control_entry == NULL )
70
0
    {
71
0
      break;
72
0
    }
73
143k
    libfwnt_access_control_entry_get_type(
74
143k
     access_control_entry,
75
143k
     &type,
76
143k
     NULL );
77
78
143k
    libfwnt_access_control_entry_get_flags(
79
143k
     access_control_entry,
80
143k
     &flags,
81
143k
     NULL );
82
83
143k
    libfwnt_access_control_entry_get_access_mask(
84
143k
     access_control_entry,
85
143k
     &access_mask,
86
143k
     NULL );
87
88
143k
    security_identifier = NULL;
89
90
143k
    if( libfwnt_access_control_entry_get_security_identifier(
91
143k
         access_control_entry,
92
143k
         &security_identifier,
93
143k
         NULL ) == 1 )
94
4.01k
    {
95
4.01k
      libfwnt_security_identifier_get_string_size(
96
4.01k
       security_identifier,
97
4.01k
       NULL,
98
4.01k
       0,
99
4.01k
       NULL );
100
4.01k
    }
101
143k
  }
102
390
} /* inspect_access_control_list */
103
104
int LLVMFuzzerTestOneInput(
105
     const uint8_t *data,
106
     size_t size )
107
766
{
108
766
  libfwnt_access_control_list_t *access_control_list = NULL;
109
766
  libfwnt_security_descriptor_t *security_descriptor = NULL;
110
766
  libfwnt_security_identifier_t *security_identifier = NULL;
111
112
766
  if( libfwnt_security_descriptor_initialize(
113
766
       &security_descriptor,
114
766
       NULL ) != 1 )
115
0
  {
116
0
    return( 0 );
117
0
  }
118
766
  libfwnt_security_descriptor_copy_from_byte_stream(
119
766
   security_descriptor,
120
766
   data,
121
766
   size,
122
766
   LIBFWNT_ENDIAN_LITTLE,
123
766
   NULL );
124
125
  /* The owner and group are managed by the security descriptor
126
   */
127
766
  security_identifier = NULL;
128
129
766
  if( libfwnt_security_descriptor_get_owner(
130
766
       security_descriptor,
131
766
       &security_identifier,
132
766
       NULL ) == 1 )
133
81
  {
134
81
    libfwnt_security_identifier_get_string_size(
135
81
     security_identifier,
136
81
     NULL,
137
81
     0,
138
81
     NULL );
139
81
  }
140
141
766
  security_identifier = NULL;
142
143
766
  if( libfwnt_security_descriptor_get_group(
144
766
       security_descriptor,
145
766
       &security_identifier,
146
766
       NULL ) == 1 )
147
96
  {
148
96
    libfwnt_security_identifier_get_string_size(
149
96
     security_identifier,
150
96
     NULL,
151
96
     0,
152
96
     NULL );
153
96
  }
154
155
766
  access_control_list = NULL;
156
157
766
  if( libfwnt_security_descriptor_get_discretionary_acl(
158
766
       security_descriptor,
159
766
       &access_control_list,
160
766
       NULL ) == 1 )
161
198
  {
162
198
    inspect_access_control_list(
163
198
     access_control_list );
164
198
  }
165
166
766
  access_control_list = NULL;
167
168
766
  if( libfwnt_security_descriptor_get_system_acl(
169
766
       security_descriptor,
170
766
       &access_control_list,
171
766
       NULL ) == 1 )
172
192
  {
173
192
    inspect_access_control_list(
174
192
     access_control_list );
175
192
  }
176
177
766
  libfwnt_security_descriptor_free(
178
766
   &security_descriptor,
179
766
   NULL );
180
181
766
  return( 0 );
182
766
}
183
184
} /* extern "C" */