summaryrefslogtreecommitdiff
path: root/Meta/Lagom/Fuzzers
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2021-03-27 15:04:24 +0000
committerAndreas Kling <kling@serenityos.org>2021-03-27 16:28:34 +0100
commit1ff6f2b4b266ff90f15d9a462c3b44f88c4c645b (patch)
tree45d9424aab63c42d61db64206588a945ee635ea6 /Meta/Lagom/Fuzzers
parente288541a9b97427a66c5ecc4b9ce4cee8a3b9bb3 (diff)
downloadserenity-1ff6f2b4b266ff90f15d9a462c3b44f88c4c645b.zip
Lagom/Fuzzers: Add fuzzer for zip file parser
Diffstat (limited to 'Meta/Lagom/Fuzzers')
-rw-r--r--Meta/Lagom/Fuzzers/CMakeLists.txt1
-rw-r--r--Meta/Lagom/Fuzzers/FuzzZip.cpp43
2 files changed, 44 insertions, 0 deletions
diff --git a/Meta/Lagom/Fuzzers/CMakeLists.txt b/Meta/Lagom/Fuzzers/CMakeLists.txt
index c2ec394880..c64e5dc7a3 100644
--- a/Meta/Lagom/Fuzzers/CMakeLists.txt
+++ b/Meta/Lagom/Fuzzers/CMakeLists.txt
@@ -42,6 +42,7 @@ add_simple_fuzzer(FuzzURL)
add_simple_fuzzer(FuzzUTF16BEDecoder)
add_simple_fuzzer(FuzzRSAKeyParsing)
add_simple_fuzzer(FuzzWAVLoader)
+add_simple_fuzzer(FuzzZip)
add_simple_fuzzer(FuzzZlibDecompression)
if (NOT ENABLE_OSS_FUZZ)
diff --git a/Meta/Lagom/Fuzzers/FuzzZip.cpp b/Meta/Lagom/Fuzzers/FuzzZip.cpp
new file mode 100644
index 0000000000..2255abfeed
--- /dev/null
+++ b/Meta/Lagom/Fuzzers/FuzzZip.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2021, the SerenityOS developers.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <LibArchive/Zip.h>
+#include <stddef.h>
+#include <stdint.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ ByteBuffer zip_data = ByteBuffer::copy(data, size);
+ auto zip_file = Archive::Zip::try_create(zip_data);
+ if (!zip_file.has_value())
+ return 0;
+
+ zip_file->for_each_member([]() {
+ return IterationDecision::Continue;
+ });
+
+ return 0;
+}