mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibCompress: Remove unused Lzma compression and decompression
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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=",
|
||||
|
||||
@@ -4,7 +4,6 @@ shared_library("LibCompress") {
|
||||
sources = [
|
||||
"Deflate.cpp",
|
||||
"Gzip.cpp",
|
||||
"Lzma.cpp",
|
||||
"PackBitsDecoder.cpp",
|
||||
"Zlib.cpp",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user