/src/zlib_uncompress_fuzzer.cc
Line | Count | Source |
1 | | // Copyright 2015 The Chromium Authors. All rights reserved. |
2 | | // Use of this source code is governed by a BSD-style license that can be |
3 | | // found in the LICENSE file. |
4 | | |
5 | | #include <stddef.h> |
6 | | #include <stdint.h> |
7 | | #include <string.h> |
8 | | |
9 | | #include "zlib.h" |
10 | | |
11 | | static Bytef buffer[256 * 1024] = { 0 }; |
12 | | |
13 | | // Entry point for LibFuzzer. |
14 | 1.52k | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
15 | 1.52k | uLongf buffer_length = static_cast<uLongf>(sizeof(buffer)); |
16 | 1.52k | if (Z_OK != uncompress(buffer, &buffer_length, data, |
17 | 1.52k | static_cast<uLong>(size))) { |
18 | 1.51k | return 0; |
19 | 1.51k | } |
20 | 1 | return 0; |
21 | 1.52k | } |