diff options
author | Michiel Visser <opensource@webmichiel.nl> | 2022-04-06 21:16:04 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-05-21 22:41:40 +0200 |
commit | 1621724123d0ad598a79d55f5af36bcf359f5101 (patch) | |
tree | 768c04cdb524f1a0d94d2c97391352a2d6e9ccbe | |
parent | 7278ad761ecb56f6b452925df6f292210e7f903d (diff) | |
download | serenity-1621724123d0ad598a79d55f5af36bcf359f5101.zip |
Meta: Add Brotli fuzzer
-rw-r--r-- | Meta/Lagom/Fuzzers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Meta/Lagom/Fuzzers/FuzzBrotli.cpp | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/Meta/Lagom/Fuzzers/CMakeLists.txt b/Meta/Lagom/Fuzzers/CMakeLists.txt index 9c74c24341..a8c7b65a62 100644 --- a/Meta/Lagom/Fuzzers/CMakeLists.txt +++ b/Meta/Lagom/Fuzzers/CMakeLists.txt @@ -19,6 +19,7 @@ function(add_simple_fuzzer name) endfunction() add_simple_fuzzer(FuzzBMPLoader LagomGfx) +add_simple_fuzzer(FuzzBrotli LagomCompress) add_simple_fuzzer(FuzzCyrillicDecoder LagomTextCodec) add_simple_fuzzer(FuzzDeflateCompression LagomCompress) add_simple_fuzzer(FuzzDeflateDecompression LagomCompress) diff --git a/Meta/Lagom/Fuzzers/FuzzBrotli.cpp b/Meta/Lagom/Fuzzers/FuzzBrotli.cpp new file mode 100644 index 0000000000..7b98b01eed --- /dev/null +++ b/Meta/Lagom/Fuzzers/FuzzBrotli.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022, the SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <LibCompress/Brotli.h> +#include <LibCore/MemoryStream.h> +#include <stdio.h> + +extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) +{ + auto bufstream_result = Core::Stream::MemoryStream::construct({ const_cast<uint8_t*>(data), size }); + if (bufstream_result.is_error()) { + dbgln("MemoryStream::construct() failed."); + return 1; + } + auto bufstream = bufstream_result.release_value(); + + auto brotli_stream = Compress::BrotliDecompressionStream { *bufstream }; + + auto uncompressed = brotli_stream.read_all(); + return uncompressed.is_error(); +} |