blob: d83f9bf82b6efad4e01c6c91fac099eebe977bba [file] [log] [blame]
Elliott Hughes62c2d532019-10-22 11:44:50 -07001// SPDX-License-Identifier: Apache-2.0
2
3#include <stddef.h>
4#include <stdint.h>
5
6#include <ziparchive/zip_archive.h>
7
Elliott Hughes36fec722020-11-13 13:33:39 -08008// See current fuzz coverage here:
9// https://android-coverage.googleplex.com/fuzz_targets/libziparchive_fuzzer/index.html
10
Elliott Hughes62c2d532019-10-22 11:44:50 -070011extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
12 ZipArchiveHandle handle = nullptr;
Elliott Hughes36fec722020-11-13 13:33:39 -080013 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 Hughes62c2d532019-10-22 11:44:50 -070025 CloseArchive(handle);
26 return 0;
27}