Skip to content

Commit

Permalink
igzip: fix header construction in Big Endian systems
Browse files Browse the repository at this point in the history
When a file contains a number of repeated '0x00' or '0xff'
bytes, the block header is copied from a precomputed header,
which only worked for Little-Endian systems.

Fixes #311.

Signed-off-by: Pablo de Lara <[email protected]>
  • Loading branch information
pablodelara authored and mdcornu committed Feb 4, 2025
1 parent e3c2d24 commit 633add1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions igzip/repeated_char_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@
/* Headers for constant 0x00 and 0xFF blocks
* This also contains the first literal character. */
const uint32_t repeated_char_header[2][5] = {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
{ 0x0121c0ec, 0xc30c0000, 0x7d57fab0, 0x49270938 }, /* Deflate header for 0x00 */
{ 0x0121c0ec, 0xc30c0000, 0x7baaff30, 0x49270938 } /* Deflate header for 0xFF */
#else
{ 0xecc02101, 0x00000cc3, 0xb0fa577d, 0x38092749 }, /* Deflate header for 0x00 */
{ 0xecc02101, 0x00000cc3, 0x30ffaa7b, 0x38092749 }, /* Deflate header for 0xFF */
#endif

};

Expand Down

0 comments on commit 633add1

Please sign in to comment.