/src/miniz/tests/checksum_fuzzer.c
Line | Count | Source |
1 | | /* Derived from zlib fuzzers at http://github.com/google/oss-fuzz/tree/master/projects/zlib, |
2 | | * see ossfuzz.sh for full license text. |
3 | | */ |
4 | | |
5 | | #include <stddef.h> |
6 | | #include <stdint.h> |
7 | | #include <inttypes.h> |
8 | | |
9 | | #include "miniz.h" |
10 | | |
11 | | static const size_t kMaxSize = 1024 * 1024; |
12 | | |
13 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataLen) |
14 | 6.13k | { |
15 | | /* Discard inputs larger than 1Mb. */ |
16 | 6.13k | if (dataLen < 1 || dataLen > kMaxSize) return 0; |
17 | | |
18 | 6.13k | uint32_t crc = crc32(0L, NULL, 0); |
19 | 6.13k | uint32_t adler = adler32(0L, NULL, 0); |
20 | | |
21 | 6.13k | crc = crc32(crc, data, (uint32_t) dataLen); |
22 | 6.13k | adler = adler32(adler, data, (uint32_t) dataLen); |
23 | | |
24 | 6.13k | return 0; |
25 | 6.13k | } |