diff options
author | Luke <luke.wilde@live.co.uk> | 2021-03-27 15:04:24 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-27 16:28:34 +0100 |
commit | 1ff6f2b4b266ff90f15d9a462c3b44f88c4c645b (patch) | |
tree | 45d9424aab63c42d61db64206588a945ee635ea6 /Meta | |
parent | e288541a9b97427a66c5ecc4b9ce4cee8a3b9bb3 (diff) | |
download | serenity-1ff6f2b4b266ff90f15d9a462c3b44f88c4c645b.zip |
Lagom/Fuzzers: Add fuzzer for zip file parser
Diffstat (limited to 'Meta')
-rw-r--r-- | Meta/Lagom/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Meta/Lagom/Fuzzers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Meta/Lagom/Fuzzers/FuzzZip.cpp | 43 |
3 files changed, 46 insertions, 1 deletions
diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index d1329fc61d..7c1ea9043f 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -43,6 +43,7 @@ endif() file(GLOB AK_SOURCES CONFIGURE_DEPENDS "../../AK/*.cpp") file(GLOB AK_TEST_SOURCES CONFIGURE_DEPENDS "../../AK/Tests/*.cpp") +file(GLOB LIBARCHIVE_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibArchive/*.cpp") file(GLOB LIBAUDIO_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibAudio/*.cpp") list(REMOVE_ITEM LIBAUDIO_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../../Userland/Libraries/LibAudio/ClientConnection.cpp") file(GLOB LIBREGEX_LIBC_SOURCES "../../Userland/Libraries/LibRegex/C/Regex.cpp") @@ -75,7 +76,7 @@ list(FILTER SHELL_SOURCES EXCLUDE REGEX ".*main.cpp$") set(LAGOM_REGEX_SOURCES ${LIBREGEX_LIBC_SOURCES} ${LIBREGEX_SOURCES}) set(LAGOM_CORE_SOURCES ${AK_SOURCES} ${LIBCORE_SOURCES}) -set(LAGOM_MORE_SOURCES ${LIBAUDIO_SOURCES} ${LIBELF_SOURCES} ${LIBIPC_SOURCES} ${LIBLINE_SOURCES} ${LIBJS_SOURCES} ${LIBJS_SUBDIR_SOURCES} ${LIBX86_SOURCES} ${LIBCRYPTO_SOURCES} ${LIBCOMPRESS_SOURCES} ${LIBCRYPTO_SUBDIR_SOURCES} ${LIBTLS_SOURCES} ${LIBTTF_SOURCES} ${LIBTEXTCODEC_SOURCES} ${LIBMARKDOWN_SOURCES} ${LIBGEMINI_SOURCES} ${LIBGFX_SOURCES} ${LIBGUI_GML_SOURCES} ${LIBHTTP_SOURCES} ${LAGOM_REGEX_SOURCES} ${SHELL_SOURCES}) +set(LAGOM_MORE_SOURCES ${LIBARCHIVE_SOURCES} ${LIBAUDIO_SOURCES} ${LIBELF_SOURCES} ${LIBIPC_SOURCES} ${LIBLINE_SOURCES} ${LIBJS_SOURCES} ${LIBJS_SUBDIR_SOURCES} ${LIBX86_SOURCES} ${LIBCRYPTO_SOURCES} ${LIBCOMPRESS_SOURCES} ${LIBCRYPTO_SUBDIR_SOURCES} ${LIBTLS_SOURCES} ${LIBTTF_SOURCES} ${LIBTEXTCODEC_SOURCES} ${LIBMARKDOWN_SOURCES} ${LIBGEMINI_SOURCES} ${LIBGFX_SOURCES} ${LIBGUI_GML_SOURCES} ${LIBHTTP_SOURCES} ${LAGOM_REGEX_SOURCES} ${SHELL_SOURCES}) # FIXME: This is a hack, because the lagom stuff can be build individually or # in combination with the system, we generate two Debug.h files. One in 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; +} |