Elliott Hughes | 62c2d53 | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | |
| 3 | #include <stddef.h> |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | #include <ziparchive/zip_archive.h> |
| 7 | |
Elliott Hughes | 36fec72 | 2020-11-13 13:33:39 -0800 | [diff] [blame] | 8 | // See current fuzz coverage here: |
| 9 | // https://android-coverage.googleplex.com/fuzz_targets/libziparchive_fuzzer/index.html |
| 10 | |
Elliott Hughes | 62c2d53 | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 11 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 12 | ZipArchiveHandle handle = nullptr; |
Elliott Hughes | 36fec72 | 2020-11-13 13:33:39 -0800 | [diff] [blame] | 13 | if (OpenArchiveFromMemory(data, size, "fuzz", &handle) == 0) { |
| 14 | // Iterate through all the entries. |
| 15 | void* cookie; |
| 16 | if (StartIteration(handle, &cookie) == 0) { |
| 17 | ZipEntry ze; |
| 18 | std::string name; |
| 19 | int result; |
| 20 | while ((result = Next(cookie, &ze, &name)) == 0) { |
| 21 | } |
| 22 | EndIteration(cookie); |
| 23 | } |
| 24 | } |
Elliott Hughes | 62c2d53 | 2019-10-22 11:44:50 -0700 | [diff] [blame] | 25 | CloseArchive(handle); |
| 26 | return 0; |
| 27 | } |