Commit Graph

26 Commits

Author SHA1 Message Date
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Marco Biscaro
8124719c3d Tests: Reorganize LibCompress unit tests
Move LibCompress unit tests to LibCompress/Tests directory and register
them with CMake's add_test. This allows us to run these tests with
ninja test instead of running a separate executable.

Also split the existing tests in 3 test files that better follow the
source code structure (inspired by AK tests).
2021-04-21 08:00:32 +02:00
Linus Groh
2b0c361d04 Everywhere: Fix a bunch of typos 2021-04-18 10:30:03 +02:00
Idan Horowitz
b3b8c01ebf LibCompress: Convert GzipDecompressor from recursive to iterative
This way a gzip compressed file that contains a large amount of small
blocks wont cause a stack overflow.
2021-03-21 15:46:35 +01:00
Idan Horowitz
974a981ded LibCompress: Convert DeflateDecompressor from recursive to iterative
This way a deflate blob that contains a large amount of small blocks
wont cause a stack overflow.
2021-03-19 23:03:04 +01:00
Idan Horowitz
ea7bdf02b8 LibCompress: fail gracefuly on invalid symbols in DeflateDecompressor 2021-03-17 21:57:16 +01:00
Idan Horowitz
071ee7c6f4 LibCompress: Check for impossible back references in DeflateDecompressor
This commit makes sure that we fail if an encoded lz77 back reference
references bytes that are outside our sliding window, instead of just
silently failing, which triggers an assertion down the line.
2021-03-17 21:57:16 +01:00
Idan Horowitz
8533cceed5 LibCompress: Fail gracefuly on missing huffman codes in DeflateDecompressor 2021-03-16 21:57:44 +01:00
Idan Horowitz
be5a8d9c7f LibCompress: Check and fail for input stream errors in DeflateDecompressor
Since we were not checking for error flags set by read_bits we would
just always read 0 as the bits' value, which in some edge cases could
lead to an infinite loop.
2021-03-16 21:57:44 +01:00
Idan Horowitz
1d8ab74cbf LibCompress: Allow partial header reads in GzipDecompressor
We now read the header into a temporary header byte array that is used
as the header once its filled up by the input stream, instead of just
ending the stream if we are out of bytes mid header.
2021-03-16 21:53:34 +01:00
Idan Horowitz
eb343296ce LibCompress: Handle and propagate stream errors in GzipDecompressor
This commit makes read short-circuit if its input stream errored,
as well as propagate error handling to wrapped sub streams, similarly
to DeflateDecompressor.
2021-03-16 14:56:50 +01:00
Idan Horowitz
ea5f83616e LibCompress+AK: Dont short-circuit error handling propagation
In the case that both the stream and the wrapped substream had errors
to be handled only one of the two would be resolved due to boolean
short circuiting. this commit ensures both are handled irregardless
of one another.
2021-03-16 14:56:50 +01:00
Idan Horowitz
a955fd4156 LibCompress+AK: Propagate error handling to wrapped streams
This ensures that when a DeflateCompressor stream is cleared of any
errors its underlying wrapped streams (InputBitStream/InputMemoryStream)
will be cleared as well and wont fail a VERIFY on destruction.
2021-03-15 21:35:48 +01:00
Idan Horowitz
f532421c9c LibCompress: Make the Zlib decompressor fail gracefuly
This commit adds a verify-less try_create method to the Zlib
decompressor to allow for graceful failures of parsing the
Zlib headers.
2021-03-15 21:35:48 +01:00
Idan Horowitz
02b4cb96f8 LibCompress: Decrease CanonicalCode's size on stack
This commit stores the bit codes as u16s instead of u32s as the
maximum code bit length in DEFLATE is 15.
2021-03-14 14:52:21 +01:00
Idan Horowitz
7e587a615e LibCompress: Handle literal only lz77 streams in DeflateCompressor
Very incompressible data could sometimes produce no backreferences
which would result in no distance huffman code being created (as it
was not needed), so VERIFY the code exists only if it is actually
needed for writing the stream.
2021-03-14 11:05:35 +01:00
Idan Horowitz
b1e3176f9f LibCompress: Replace goto with simple recursion in DeflateCompressor
This is just a bit easier on the eyes :^)
2021-03-13 23:50:07 +01:00
Idan Horowitz
135751c3a2 LibCompress: Implement GZip compression
This commit implements a stream compressor for the gzip
specification (RFC 1952), which is essentially a thin
wrapper around the DEFLATE compression format.
2021-03-13 20:07:25 +01:00
Idan Horowitz
bcbfa7db62 LibCompress: Implement DEFLATE compression
This commit adds a fully functional DEFLATE compression
implementation that can be used to implement compression
for higher level formats like gzip, zlib or zip.

A large part of this commit is based on Hans Wennborg's
great article about the DEFLATE and zip specifications:
https://www.hanshq.net/zip.html
2021-03-13 20:07:25 +01:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Jelle Raaijmakers
f9f9cda025 LibCompress: Rename libcompression.so to libcompress.so 2021-03-07 18:14:54 +01:00
Idan Horowitz
c12781a6a2 LibCore+LibHTTP+LibGfx: Switch to LibCompress
This commit removes the only 3rd party library (and its usages)
in serenity: puff, which is used for deflate decompression. and
replaces it with the existing original serenity implementation
in LibCompress. :^)
2021-03-03 23:42:32 +01:00
Linus Groh
e265054c12 Everywhere: Remove a bunch of redundant 'AK::' namespace prefixes
This is basically just for consistency, it's quite strange to see
multiple AK container types next to each other, some with and some
without the namespace prefix - we're 'using AK::Foo;' a lot and should
leverage that. :^)
2021-02-26 16:59:56 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Linus Groh
421587c15c Everywhere: Fix typos 2021-01-22 18:41:29 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00