Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect LZ4 end of block conditions #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rlespinet
Copy link

@rlespinet rlespinet commented Feb 16, 2023

Lz4js compress can produce outputs that are not conformant with LZ4 official format. This is due to end of block conditions spcified in https://github.com/lz4/lz4/blob/dev/doc/lz4_Block_format.md and more specifically the following:

"The last match must start at least 12 bytes before the end of block"

For example, prior to this change, when compressing the following string (ASCII encoded) with lz4js

"AbcdefghijklmnopAbcdefghijk"

a match starting only 11 bytes before the end of the output buffer (corresponding to "Abcdefghijk") would have been created, leading to an invalid output bitstream. Official LZ4 decoder would fail to decompress this bitstream. This commit prevents matches occuring (strictly) less than 12 bytes before the end of the block.

Fixes #12

Lz4js compress can produce outputs that are not conformant with LZ4
official format. This is due to end of block conditions spcified in
https://github.com/lz4/lz4/blob/dev/doc/lz4_Block_format.md and more
specifically the following:

    "The last match must start at least 12 bytes before the end of block"

For example, prior to this change, when compressing the following
string (ASCII encoded) with lz4js

    "AbcdefghijklmnopAbcdefghijk"

a match starting only 11 bytes before the end of the output buffer
(corresponding to "Abcdefghijk") would have been created, leading to
an invalid output bitstream. Official LZ4 decoder would fail to
decompress this bitstream. This commit prevents matches occuring
(strictly) less than 12 bytes before the end of the block.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compression does not respect LZ4 official End of block conditions
1 participant