/src/serenity/Meta/Lagom/Fuzzers/FuzzLzmaRoundtrip.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2023, Tim Schumacher <timschumi@gmx.de>. |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <AK/MemoryStream.h> |
8 | | #include <LibCompress/Lzma.h> |
9 | | |
10 | | extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) |
11 | 2.53k | { |
12 | 2.53k | AK::set_debug_enabled(false); |
13 | | |
14 | 2.53k | AllocatingMemoryStream stream {}; |
15 | | |
16 | 2.53k | auto compressor = MUST(Compress::LzmaCompressor::create_container(MaybeOwned<Stream> { stream }, {})); |
17 | 2.53k | MUST(compressor->write_until_depleted({ data, size })); |
18 | 2.53k | MUST(compressor->flush()); |
19 | | |
20 | 2.53k | auto decompressor = MUST(Compress::LzmaDecompressor::create_from_container(MaybeOwned<Stream> { stream })); |
21 | 2.53k | auto result = MUST(decompressor->read_until_eof()); |
22 | | |
23 | 2.53k | VERIFY((ReadonlyBytes { data, size }) == result.span()); |
24 | | |
25 | 2.53k | return 0; |
26 | 2.53k | } |