diff options
Diffstat (limited to 'Meta/Lagom/Fuzzers/FuzzBrotli.cpp')
-rw-r--r-- | Meta/Lagom/Fuzzers/FuzzBrotli.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
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(); +} |