summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCompress/Deflate.h
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-03-28 11:28:04 -0400
committerAndreas Kling <kling@serenityos.org>2023-03-29 07:19:14 +0200
commit20aaab47f9dab40b37b85a1044ac43909ab50443 (patch)
treedb77e66401853ef2c92946e7189b6127a5f2d75f /Userland/Libraries/LibCompress/Deflate.h
parent94236621074d74ff982aba1580404cbdab1e73b0 (diff)
downloadserenity-20aaab47f9dab40b37b85a1044ac43909ab50443.zip
LibCompress: Use a bit stream for the entire GZIP decompression process
We currently mix normal and bit streams during GZIP decompression, where the latter is a wrapper around the former. This isn't causing issues now as the underlying bit stream buffer is a byte, so the normal stream can pick up where the bit stream left off. In order to increase the size of that buffer though, the normal stream will not be able to assume it can resume reading after the bit stream. The buffer can easily contain more bits than it was meant to read, so when the normal stream resumes, there may be N bits leftover in the bit stream that the normal stream was meant to read. To avoid weird behavior when mixing streams, this changes the GZIP decompressor to always read from a bit stream.
Diffstat (limited to 'Userland/Libraries/LibCompress/Deflate.h')
-rw-r--r--Userland/Libraries/LibCompress/Deflate.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibCompress/Deflate.h b/Userland/Libraries/LibCompress/Deflate.h
index c62f1bd34e..feb6e088ec 100644
--- a/Userland/Libraries/LibCompress/Deflate.h
+++ b/Userland/Libraries/LibCompress/Deflate.h
@@ -76,7 +76,7 @@ public:
friend CompressedBlock;
friend UncompressedBlock;
- static ErrorOr<NonnullOwnPtr<DeflateDecompressor>> construct(MaybeOwned<Stream> stream);
+ static ErrorOr<NonnullOwnPtr<DeflateDecompressor>> construct(MaybeOwned<LittleEndianInputBitStream> stream);
~DeflateDecompressor();
virtual ErrorOr<Bytes> read_some(Bytes) override;
@@ -88,7 +88,7 @@ public:
static ErrorOr<ByteBuffer> decompress_all(ReadonlyBytes);
private:
- DeflateDecompressor(MaybeOwned<Stream> stream, CircularBuffer buffer);
+ DeflateDecompressor(MaybeOwned<LittleEndianInputBitStream> stream, CircularBuffer buffer);
ErrorOr<u32> decode_length(u32);
ErrorOr<u32> decode_distance(u32);