Commit 6f511158 authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Extend minizip fuzzer to fuzz encrypted zip files.

BUG=900749

Change-Id: Id2da44c92c3e53aa08c60e7ae7de6eac6cd32b44
Reviewed-on: https://chromium-review.googlesource.com/c/1322169Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#605949}
parent 8cb84fbd
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
#include "third_party/minizip/src/mz_strm_mem.h" #include "third_party/minizip/src/mz_strm_mem.h"
#include "third_party/minizip/src/mz_zip.h" #include "third_party/minizip/src/mz_zip.h"
namespace {
const char kTestPassword[] = "test123";
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
void* stream = mz_stream_mem_create(nullptr); void* stream = mz_stream_mem_create(nullptr);
mz_stream_mem_set_buffer( mz_stream_mem_set_buffer(
...@@ -24,13 +28,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { ...@@ -24,13 +28,15 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (result == MZ_OK) { if (result == MZ_OK) {
result = mz_zip_goto_first_entry(zip_file); result = mz_zip_goto_first_entry(zip_file);
while (result == MZ_OK) { while (result == MZ_OK) {
result = mz_zip_entry_read_open(zip_file, 0, nullptr); mz_zip_file* file_info = nullptr;
result = mz_zip_entry_get_info(zip_file, &file_info);
if (result != MZ_OK) { if (result != MZ_OK) {
break; break;
} }
mz_zip_file* file_info = nullptr; bool is_encrypted = (file_info->flag & MZ_ZIP_FLAG_ENCRYPTED);
result = mz_zip_entry_get_info(zip_file, &file_info); result = mz_zip_entry_read_open(zip_file, 0,
is_encrypted ? kTestPassword : nullptr);
if (result != MZ_OK) { if (result != MZ_OK) {
break; break;
} }
......
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