summaryrefslogtreecommitdiff
path: root/Meta/Lagom/Fuzzers
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2021-03-13 23:45:22 +0000
committerAndreas Kling <kling@serenityos.org>2021-03-14 11:28:12 +0100
commitc983e42e8cb299905d87bddc43f00c2fd109022b (patch)
treeae9c5893f9883ed901703b0e405babf9f8c11379 /Meta/Lagom/Fuzzers
parentd27e6f0961ac4e2df943f4bf4061b21c4def83f7 (diff)
downloadserenity-c983e42e8cb299905d87bddc43f00c2fd109022b.zip
Lagom/Fuzzers: Add fuzzers for the new Gzip and Deflate compressors
Diffstat (limited to 'Meta/Lagom/Fuzzers')
-rw-r--r--Meta/Lagom/Fuzzers/CMakeLists.txt8
-rw-r--r--Meta/Lagom/Fuzzers/FuzzDeflateCompression.cpp34
-rw-r--r--Meta/Lagom/Fuzzers/FuzzDeflateDecompression.cpp (renamed from Meta/Lagom/Fuzzers/FuzzDeflate.cpp)0
-rw-r--r--Meta/Lagom/Fuzzers/FuzzGzipCompression.cpp34
-rw-r--r--Meta/Lagom/Fuzzers/FuzzGzipDecompression.cpp (renamed from Meta/Lagom/Fuzzers/FuzzGzip.cpp)0
-rw-r--r--Meta/Lagom/Fuzzers/FuzzZlibDecompression.cpp (renamed from Meta/Lagom/Fuzzers/FuzzZlib.cpp)0
6 files changed, 73 insertions, 3 deletions
diff --git a/Meta/Lagom/Fuzzers/CMakeLists.txt b/Meta/Lagom/Fuzzers/CMakeLists.txt
index d227ffa19e..c2ec394880 100644
--- a/Meta/Lagom/Fuzzers/CMakeLists.txt
+++ b/Meta/Lagom/Fuzzers/CMakeLists.txt
@@ -16,11 +16,13 @@ function(add_simple_fuzzer name)
endfunction()
add_simple_fuzzer(FuzzBMPLoader)
-add_simple_fuzzer(FuzzDeflate)
+add_simple_fuzzer(FuzzDeflateCompression)
+add_simple_fuzzer(FuzzDeflateDecompression)
add_simple_fuzzer(FuzzELF)
add_simple_fuzzer(FuzzGemini)
add_simple_fuzzer(FuzzGIFLoader)
-add_simple_fuzzer(FuzzGzip)
+add_simple_fuzzer(FuzzGzipCompression)
+add_simple_fuzzer(FuzzGzipDecompression)
add_simple_fuzzer(FuzzICOLoader)
add_simple_fuzzer(FuzzJPGLoader)
add_simple_fuzzer(FuzzPNGLoader)
@@ -40,7 +42,7 @@ add_simple_fuzzer(FuzzURL)
add_simple_fuzzer(FuzzUTF16BEDecoder)
add_simple_fuzzer(FuzzRSAKeyParsing)
add_simple_fuzzer(FuzzWAVLoader)
-add_simple_fuzzer(FuzzZlib)
+add_simple_fuzzer(FuzzZlibDecompression)
if (NOT ENABLE_OSS_FUZZ)
set(CMAKE_EXE_LINKER_FLAGS "${ORIGINAL_CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
diff --git a/Meta/Lagom/Fuzzers/FuzzDeflateCompression.cpp b/Meta/Lagom/Fuzzers/FuzzDeflateCompression.cpp
new file mode 100644
index 0000000000..430ac90490
--- /dev/null
+++ b/Meta/Lagom/Fuzzers/FuzzDeflateCompression.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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 <LibCompress/Deflate.h>
+#include <stdio.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ auto result = Compress::DeflateCompressor::compress_all(ReadonlyBytes { data, size });
+ return result.has_value();
+}
diff --git a/Meta/Lagom/Fuzzers/FuzzDeflate.cpp b/Meta/Lagom/Fuzzers/FuzzDeflateDecompression.cpp
index 1add55efb1..1add55efb1 100644
--- a/Meta/Lagom/Fuzzers/FuzzDeflate.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzDeflateDecompression.cpp
diff --git a/Meta/Lagom/Fuzzers/FuzzGzipCompression.cpp b/Meta/Lagom/Fuzzers/FuzzGzipCompression.cpp
new file mode 100644
index 0000000000..69ac5f4108
--- /dev/null
+++ b/Meta/Lagom/Fuzzers/FuzzGzipCompression.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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 <LibCompress/Gzip.h>
+#include <stdio.h>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+ auto result = Compress::GzipCompressor::compress_all(ReadonlyBytes { data, size });
+ return result.has_value();
+}
diff --git a/Meta/Lagom/Fuzzers/FuzzGzip.cpp b/Meta/Lagom/Fuzzers/FuzzGzipDecompression.cpp
index 4e8f1a0791..4e8f1a0791 100644
--- a/Meta/Lagom/Fuzzers/FuzzGzip.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzGzipDecompression.cpp
diff --git a/Meta/Lagom/Fuzzers/FuzzZlib.cpp b/Meta/Lagom/Fuzzers/FuzzZlibDecompression.cpp
index 5d9931a627..5d9931a627 100644
--- a/Meta/Lagom/Fuzzers/FuzzZlib.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzZlibDecompression.cpp