]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/isa-l/tests/fuzz/igzip_fuzz_inflate.c
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / isa-l / tests / fuzz / igzip_fuzz_inflate.c
1 #define _FILE_OFFSET_BITS 64
2 #include <stdio.h>
3 #include <assert.h>
4 #include <zlib.h>
5 #include "huff_codes.h"
6 #include "igzip_lib.h"
7 #include "test.h"
8
9 extern int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size);
10
11 int main(int argc, char *argv[])
12 {
13 FILE *in = NULL;
14 unsigned char *in_buf = NULL;
15 uint64_t in_file_size;
16
17 if (argc != 2) {
18 fprintf(stderr, "Usage: isal_fuzz_inflate <infile>\n");
19 exit(1);
20 }
21 in = fopen(argv[1], "rb");
22 if (!in) {
23 fprintf(stderr, "Can't open %s for reading\n", argv[1]);
24 exit(1);
25 }
26 in_file_size = get_filesize(in);
27 in_buf = malloc(in_file_size);
28
29 if (in_buf == NULL) {
30 fprintf(stderr, "Failed to malloc input and outputs buffers\n");
31 exit(1);
32 }
33
34 fread(in_buf, 1, in_file_size, in);
35
36 return LLVMFuzzerTestOneInput(in_buf, in_file_size);
37 }