Coverage Report

Created: 2026-12-01 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libwrc/ossfuzz/manifest_resource_fuzzer.cc
Line
Count
Source
1
/*
2
 * OSS-Fuzz target for libwrc manifest_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
393
{
35
393
  uint8_t utf8_string[ 384 ];
36
393
  uint16_t utf16_string[ 192 ];
37
38
393
  libwrc_manifest_resource_t *manifest_resource = NULL;
39
393
  size_t utf8_string_size                       = 0;
40
393
  size_t utf16_string_size                      = 0;
41
42
393
  if( libwrc_manifest_resource_initialize(
43
393
       &manifest_resource,
44
393
       NULL ) != 1 )
45
0
  {
46
0
    return( 0 );
47
0
  }
48
393
  if( libwrc_manifest_resource_read(
49
393
       manifest_resource,
50
393
       data,
51
393
       size,
52
393
       NULL ) == 1 )
53
393
  {
54
393
    if( libwrc_manifest_resource_get_utf8_string_size(
55
393
              manifest_resource,
56
393
              &utf8_string_size,
57
393
              NULL ) == 1 )
58
316
    {
59
316
      if( utf8_string_size > 0 )
60
315
      {
61
315
        libwrc_manifest_resource_get_utf8_string(
62
315
           manifest_resource,
63
315
           utf8_string,
64
315
           384,
65
315
           NULL );
66
315
      }
67
316
    }
68
393
    if( libwrc_manifest_resource_get_utf16_string_size(
69
393
              manifest_resource,
70
393
              &utf16_string_size,
71
393
              NULL ) == 1 )
72
316
    {
73
316
      if( utf16_string_size > 0 )
74
315
      {
75
315
        libwrc_manifest_resource_get_utf16_string(
76
315
           manifest_resource,
77
315
           utf16_string,
78
315
           192,
79
315
           NULL );
80
315
      }
81
316
    }
82
393
  }
83
393
  libwrc_manifest_resource_free(
84
393
   &manifest_resource,
85
393
   NULL );
86
87
393
  return( 0 );
88
393
}
89
90
} /* extern "C" */