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

read_non_compressed_block is broken #2

Open
joziasdelrios opened this issue Jun 25, 2024 · 2 comments
Open

read_non_compressed_block is broken #2

joziasdelrios opened this issue Jun 25, 2024 · 2 comments

Comments

@joziasdelrios
Copy link

Per RFC-1951, the non-compressed block has 16-bit lengths, instead of 8-bit.
Then read_non_compressed_block should consume 8-bit instead of 16-bit lengths,
Also, the read_next_byte function makes a wrong byte alignment, as offset calculation is wrong.

@joziasdelrios
Copy link
Author

Considering an example ASCII text file of 4 bytes (octets) with contents "1234", its gunzip compressed blocks (per RFC-1952) is composed of the following byte sequence (hexadecimal):
01 04 00 FB FF 31 32 33 34 [CRC-32] 04 00 00 00
First byte 0x01 has BFINAL=1 and BTYPE=00b as expected for a single/last-block without compression. Higher 5 bits are skipped for byte alignment.

@joziasdelrios
Copy link
Author

04 00 and FB FF means the uncompressed block length of 4 written with 16-bit, non-inverted and then bitwise inverted.

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

No branches or pull requests

1 participant