Coverage Report

Created: 2026-09-01 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/zip/fuzz/fuzz_entry.c
Line
Count
Source
1
#include "zip.h"
2
#include <stdint.h>
3
#include <stdlib.h>
4
5
3.15k
int LLVMFuzzerTestOneInput(const uint8_t *data, const size_t size) {
6
  /* Discard inputs larger than 1MB. */
7
3.15k
  static const size_t MaxSize = 1024 * 1024;
8
3.15k
  if (size < 1 || size > MaxSize) {
9
0
    return 0;
10
0
  }
11
12
3.15k
  void *buf = NULL;
13
3.15k
  size_t bufsize = 0;
14
3.15k
  struct zip_t *zip = zip_stream_open((const char *)data, size, 0, 'r');
15
3.15k
  if (NULL == zip) {
16
1.31k
    goto end;
17
1.31k
  }
18
19
1.83k
  const ssize_t zip_entries_count = zip_entries_total(zip);
20
21
1.83k
  if (zip_entries_count <= 0) {
22
28
    goto end;
23
28
  }
24
25
1.81k
  if (0 != zip_entry_openbyindex(zip, 0)) {
26
63
    goto end;
27
63
  }
28
29
1.74k
  zip_entry_read(zip, &buf, &bufsize);
30
31
3.15k
end:
32
3.15k
  zip_entry_close(zip);
33
3.15k
  if (NULL != zip) {
34
1.83k
    zip_close(zip);
35
1.83k
  }
36
3.15k
  free(buf);
37
3.15k
  return 0;
38
1.74k
}