Commit 4e74931c authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Limit the number of files minizip_uncompress_fuzzer attempts to open.

If the input zip file contains too many files, it's possible for the
fuzzer to take too long to process every file. Cap the number of files
processed to keep fuzz time to a reasonable level.

BUG=933464

Change-Id: Icb01a4c4ca447aea1b1692a4cf4da92d1fe773cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1547540Reviewed-by: default avatarOliver Chang <ochang@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646679}
parent 6b056c68
...@@ -15,6 +15,7 @@ namespace { ...@@ -15,6 +15,7 @@ namespace {
const char kTestPassword[] = "test123"; const char kTestPassword[] = "test123";
const char kTestFileName[] = "foo"; const char kTestFileName[] = "foo";
const char kTestFileNameUppercase[] = "FOO"; const char kTestFileNameUppercase[] = "FOO";
const int kMaxFiles = 128;
} }
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
...@@ -37,7 +38,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { ...@@ -37,7 +38,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
mz_zip_get_number_entry(zip_file, &num_entries); mz_zip_get_number_entry(zip_file, &num_entries);
result = mz_zip_goto_first_entry(zip_file); result = mz_zip_goto_first_entry(zip_file);
while (result == MZ_OK) { for (int i = 0; result == MZ_OK && i < kMaxFiles; i++) {
mz_zip_file* file_info = nullptr; mz_zip_file* file_info = nullptr;
result = mz_zip_entry_get_info(zip_file, &file_info); result = mz_zip_entry_get_info(zip_file, &file_info);
if (result != MZ_OK) { if (result != MZ_OK) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment