Coverage Report

Created: 2026-12-01 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwrc/ossfuzz/mui_resource_fuzzer.cc
Line
Count
Source
1
/*
2
 * OSS-Fuzz target for libwrc mui_resource type
3
 *
4
 * Copyright (C) 2011-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_libwrc.h"
30
31
int LLVMFuzzerTestOneInput(
32
     const uint8_t *data,
33
     size_t size )
34
1.27k
{
35
1.27k
  uint8_t utf8_string[ 384 ];
36
1.27k
  uint16_t utf16_string[ 192 ];
37
38
1.27k
  libwrc_mui_resource_t *mui_resource = NULL;
39
1.27k
  size_t utf8_string_size             = 0;
40
1.27k
  size_t utf16_string_size            = 0;
41
1.27k
  uint32_t file_type                  = 0;
42
1.27k
  int result                          = 0;
43
44
1.27k
  if( libwrc_mui_resource_initialize(
45
1.27k
       &mui_resource,
46
1.27k
       NULL ) != 1 )
47
0
  {
48
0
    return( 0 );
49
0
  }
50
1.27k
  if( libwrc_mui_resource_read(
51
1.27k
       mui_resource,
52
1.27k
       data,
53
1.27k
       size,
54
1.27k
       NULL ) == 1 )
55
550
  {
56
550
    libwrc_mui_resource_get_file_type(
57
550
     mui_resource,
58
550
     &file_type,
59
550
     NULL );
60
550
    if( libwrc_mui_resource_get_utf8_main_name_size(
61
550
              mui_resource,
62
550
              &utf8_string_size,
63
550
              NULL ) == 1 )
64
269
    {
65
269
      if( utf8_string_size > 0 )
66
266
      {
67
266
        libwrc_mui_resource_get_utf8_main_name(
68
266
         mui_resource,
69
266
         utf8_string,
70
266
         384,
71
266
         NULL );
72
266
      }
73
269
    }
74
550
    if( libwrc_mui_resource_get_utf8_mui_name_size(
75
550
              mui_resource,
76
550
              &utf8_string_size,
77
550
              NULL ) == 1 )
78
159
    {
79
159
      if( utf8_string_size > 0 )
80
157
      {
81
157
        libwrc_mui_resource_get_utf8_mui_name(
82
157
         mui_resource,
83
157
         utf8_string,
84
157
         384,
85
157
         NULL );
86
157
      }
87
159
    }
88
550
    if( libwrc_mui_resource_get_utf8_language_size(
89
550
              mui_resource,
90
550
              &utf8_string_size,
91
550
              NULL ) == 1 )
92
178
    {
93
178
      if( utf8_string_size > 0 )
94
170
      {
95
170
        libwrc_mui_resource_get_utf8_language(
96
170
         mui_resource,
97
170
         utf8_string,
98
170
         384,
99
170
         NULL );
100
170
      }
101
178
    }
102
550
    if( libwrc_mui_resource_get_utf8_fallback_language_size(
103
550
              mui_resource,
104
550
              &utf8_string_size,
105
550
              NULL ) == 1 )
106
178
    {
107
178
      if( utf8_string_size > 0 )
108
170
      {
109
170
        libwrc_mui_resource_get_utf8_fallback_language(
110
170
         mui_resource,
111
170
         utf8_string,
112
170
         384,
113
170
         NULL );
114
170
      }
115
178
    }
116
550
    result = libwrc_mui_resource_get_utf16_main_name_size(
117
550
             mui_resource,
118
550
             &utf16_string_size,
119
550
             NULL );
120
121
550
    if( result == 1 )
122
269
    {
123
269
      if( utf16_string_size > 0 )
124
266
      {
125
266
        libwrc_mui_resource_get_utf16_main_name(
126
266
         mui_resource,
127
266
         utf16_string,
128
266
         192,
129
266
         NULL );
130
266
      }
131
269
    }
132
550
  }
133
1.27k
  libwrc_mui_resource_free(
134
1.27k
   &mui_resource,
135
1.27k
   NULL );
136
137
1.27k
  return( 0 );
138
1.27k
}
139
140
} /* extern "C" */