summaryrefslogtreecommitdiff
path: root/Meta/Lagom/Fuzzers/FuzzBrotli.cpp
blob: 6011e664bdf9147b41c27c301abd053eea9ab755 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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({ data, size });
    if (bufstream_result.is_error()) {
        dbgln("MemoryStream::construct() failed.");
        return 0;
    }
    auto bufstream = bufstream_result.release_value();

    auto brotli_stream = Compress::BrotliDecompressionStream { *bufstream };

    (void)brotli_stream.read_until_eof();
    return 0;
}