Coverage Report

Created: 2026-04-09 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/c-blosc2/tests/fuzz/fuzz_decompress_chunk.c
Line
Count
Source
1
#include <stdint.h>
2
#include <stdlib.h>
3
4
#include <blosc2.h>
5
6
#ifdef __cplusplus
7
extern "C" {
8
#endif
9
10
10.9k
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
11
10.9k
  size_t nbytes = 0, cbytes = 0, blocksize = 0;
12
10.9k
  void *output = NULL;
13
14
10.9k
  if (size < BLOSC_MIN_HEADER_LENGTH) {
15
6
    return 0;
16
6
  }
17
18
10.9k
  blosc2_init();
19
10.9k
  blosc2_set_nthreads(1);
20
10.9k
  blosc1_cbuffer_sizes(data, &nbytes, &cbytes, &blocksize);
21
22
10.9k
  if (cbytes != size || nbytes == 0) {
23
198
    blosc2_destroy();
24
198
    return 0;
25
198
  }
26
10.7k
  if (blosc1_cbuffer_validate(data, size, &nbytes) != 0) {
27
    /* Unexpected `nbytes` specified in blosc header */
28
53
    blosc2_destroy();
29
53
    return 0;
30
53
  }
31
32
10.6k
  output = malloc(cbytes);
33
10.6k
  if (output != NULL) {
34
10.6k
    blosc2_decompress(data, (int32_t)size, output, (int32_t)cbytes);
35
10.6k
    free(output);
36
10.6k
  }
37
38
10.6k
  blosc2_destroy();
39
10.6k
  return 0;
40
10.7k
}
41
42
#ifdef __cplusplus
43
}
44
#endif