LibCompress: Remove unused Lzma compression and decompression

This commit is contained in:
Undefine
2025-02-08 23:21:27 +01:00
committed by Sam Atkins
parent f30fd8af4c
commit 0c882c441e
12 changed files with 0 additions and 1938 deletions

View File

@@ -33,7 +33,6 @@ set(LIBWEB_CSS_ANIMATION_DEBUG ON)
set(LIBWEB_CSS_DEBUG ON)
set(LIBWEB_WASM_DEBUG ON)
set(LINE_EDITOR_DEBUG ON)
set(LZMA_DEBUG ON)
set(LZW_DEBUG ON)
set(MACH_PORT_DEBUG ON)
set(MATROSKA_DEBUG ON)

View File

@@ -1,38 +0,0 @@
/*
* Copyright (c) 2023, Tim Schumacher <timschumi@gmx.de>.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/MemoryStream.h>
#include <LibCompress/Lzma.h>
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
AK::set_debug_enabled(false);
// LibFuzzer has a default memory limit of 2048 MB, so limit the dictionary size to a
// reasonable number to make sure that we don't actually run into it by allocating a
// huge dictionary. The chosen value is double of what the largest dictionary in the
// specifications test files is, so it should be more than enough for fuzzing everything
// that we would want to fuzz.
constexpr size_t largest_reasonable_dictionary_size = 16 * MiB;
if (size >= sizeof(Compress::LzmaHeader)) {
auto const* header = reinterpret_cast<Compress::LzmaHeader const*>(data);
if (header->dictionary_size() > largest_reasonable_dictionary_size)
return -1;
}
auto stream = make<FixedMemoryStream>(ReadonlyBytes { data, size });
auto decompressor_or_error = Compress::LzmaDecompressor::create_from_container(move(stream));
if (decompressor_or_error.is_error())
return 0;
auto decompressor = decompressor_or_error.release_value();
while (!decompressor->is_eof()) {
auto maybe_error = decompressor->discard(4096);
if (maybe_error.is_error())
break;
}
return 0;
}

View File

@@ -1,26 +0,0 @@
/*
* Copyright (c) 2023, Tim Schumacher <timschumi@gmx.de>.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/MemoryStream.h>
#include <LibCompress/Lzma.h>
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
{
AK::set_debug_enabled(false);
AllocatingMemoryStream stream {};
auto compressor = MUST(Compress::LzmaCompressor::create_container(MaybeOwned<Stream> { stream }, {}));
MUST(compressor->write_until_depleted({ data, size }));
MUST(compressor->flush());
auto decompressor = MUST(Compress::LzmaDecompressor::create_from_container(MaybeOwned<Stream> { stream }));
auto result = MUST(decompressor->read_until_eof());
VERIFY((ReadonlyBytes { data, size }) == result.span());
return 0;
}

View File

@@ -12,8 +12,6 @@ set(FUZZER_TARGETS
JPEGLoader
Js
JsonParser
LzmaDecompression
LzmaRoundtrip
MatroskaReader
MD5
PEM
@@ -56,8 +54,6 @@ set(FUZZER_DEPENDENCIES_GzipRoundtrip LibCompress)
set(FUZZER_DEPENDENCIES_ICOLoader LibGfx)
set(FUZZER_DEPENDENCIES_JPEGLoader LibGfx)
set(FUZZER_DEPENDENCIES_Js LibJS LibGC)
set(FUZZER_DEPENDENCIES_LzmaDecompression LibCompress)
set(FUZZER_DEPENDENCIES_LzmaRoundtrip LibCompress)
set(FUZZER_DEPENDENCIES_MatroskaReader LibMedia)
set(FUZZER_DEPENDENCIES_MD5 LibCrypto)
set(FUZZER_DEPENDENCIES_PEM LibCrypto)

View File

@@ -254,7 +254,6 @@ write_cmake_config("ak_debug_gen") {
"LIBWEB_CSS_DEBUG=",
"LIBWEB_WASM_DEBUG=",
"LINE_EDITOR_DEBUG=",
"LZMA_DEBUG=",
"LZW_DEBUG=",
"MACH_PORT_DEBUG=",
"MATROSKA_DEBUG=",

View File

@@ -4,7 +4,6 @@ shared_library("LibCompress") {
sources = [
"Deflate.cpp",
"Gzip.cpp",
"Lzma.cpp",
"PackBitsDecoder.cpp",
"Zlib.cpp",
]