Coverage Report

Created: 2026-12-01 07:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libfvde/ossfuzz/checksum_fuzzer.cc
Line
Count
Source
1
/*
2
 * OSS-Fuzz target for libfvde checksum type
3
 *
4
 * Copyright (C) 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_libbfio.h"
30
#include "ossfuzz_libfvde.h"
31
32
#include "../libfvde/libfvde_checksum.h"
33
34
int LLVMFuzzerTestOneInput(
35
     const uint8_t *data,
36
     size_t size )
37
8.90k
{
38
8.90k
  uint32_t checksum                    = 0;
39
8.90k
  uint32_t initial_value               = 0;
40
41
  /* Note the weak CRC-32 polynomial is 0x82f63b78.
42
   */
43
8.90k
  libfvde_checksum_initialize_crc32_table(
44
8.90k
   0x82f63b78UL );
45
46
8.90k
  libfvde_checksum_calculate_weak_crc32(
47
8.90k
   &checksum,
48
8.90k
   data,
49
8.90k
   size,
50
8.90k
   0x82f63b78UL,
51
8.90k
   NULL );
52
53
8.90k
  initial_value = checksum ^ 0xffffffffUL;
54
55
8.90k
  libfvde_checksum_calculate_weak_crc32(
56
8.90k
   &checksum,
57
8.90k
   data,
58
8.90k
   size,
59
8.90k
   initial_value,
60
   NULL );
61
8.90k
  return( 0 );
62
8.90k
}
63
64
} /* extern "C" */