Coverage Report

Created: 2025-11-11 06:58

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.33k
int LLVMFuzzerTestOneInput(const uint8_t *data, const size_t size) {
6
  /* Discard inputs larger than 1MB. */
7
3.33k
  static const size_t MaxSize = 1024 * 1024;
8
3.33k
  if (size < 1 || size > MaxSize) {
9
0
    return 0;
10
0
  }
11
12
3.33k
  void *buf = NULL;
13
3.33k
  size_t bufsize = 0;
14
3.33k
  struct zip_t *zip = zip_stream_open((const char *)data, size, 0, 'r');
15
3.33k
  if (NULL == zip) {
16
1.37k
    goto end;
17
1.37k
  }
18
19
1.96k
  const ssize_t zip_entries_count = zip_entries_total(zip);
20
21
1.96k
  if (zip_entries_count <= 0) {
22
54
    goto end;
23
54
  }
24
25
1.90k
  if (0 != zip_entry_openbyindex(zip, 0)) {
26
65
    goto end;
27
65
  }
28
29
1.84k
  zip_entry_read(zip, &buf, &bufsize);
30
31
3.33k
end:
32
3.33k
  zip_entry_close(zip);
33
3.33k
  if (NULL != zip) {
34
1.96k
    zip_close(zip);
35
1.96k
  }
36
3.33k
  free(buf);
37
3.33k
  return 0;
38
1.84k
}