From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/isa-l/tests/fuzz/igzip_fuzz_inflate.c | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/isa-l/tests/fuzz/igzip_fuzz_inflate.c (limited to 'src/isa-l/tests/fuzz/igzip_fuzz_inflate.c') diff --git a/src/isa-l/tests/fuzz/igzip_fuzz_inflate.c b/src/isa-l/tests/fuzz/igzip_fuzz_inflate.c new file mode 100644 index 000000000..b28739d3b --- /dev/null +++ b/src/isa-l/tests/fuzz/igzip_fuzz_inflate.c @@ -0,0 +1,41 @@ +#define _FILE_OFFSET_BITS 64 +#include +#include +#include +#include +#include "huff_codes.h" +#include "igzip_lib.h" +#include "test.h" + +extern int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size); + +int main(int argc, char *argv[]) +{ + FILE *in = NULL; + unsigned char *in_buf = NULL; + uint64_t in_file_size; + + if (argc != 2) { + fprintf(stderr, "Usage: isal_fuzz_inflate \n"); + exit(1); + } + in = fopen(argv[1], "rb"); + if (!in) { + fprintf(stderr, "Can't open %s for reading\n", argv[1]); + exit(1); + } + in_file_size = get_filesize(in); + in_buf = malloc(in_file_size); + + if (in_buf == NULL) { + fprintf(stderr, "Failed to malloc input and outputs buffers\n"); + exit(1); + } + + if (fread(in_buf, 1, in_file_size, in) != in_file_size) { + fprintf(stderr, "Failed to read from %s\n", argv[1]); + exit(1); + } + + return LLVMFuzzerTestOneInput(in_buf, in_file_size); +} -- cgit v1.2.3