1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 17:44:56 +09:00

Meta: Add Brotli fuzzer

This commit is contained in:
Michiel Visser 2022-04-06 21:16:04 +02:00 committed by Andreas Kling
parent 7278ad761e
commit 1621724123
Notes: sideshowbarker 2024-07-17 10:43:24 +09:00
2 changed files with 25 additions and 0 deletions

View file

@ -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();
}