Skip to content

Commit 633add1

Browse files
pablodelaramdcornu
authored andcommitted
igzip: fix header construction in Big Endian systems
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]>
1 parent e3c2d24 commit 633add1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

igzip/repeated_char_result.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@
5959
/* Headers for constant 0x00 and 0xFF blocks
6060
* This also contains the first literal character. */
6161
const uint32_t repeated_char_header[2][5] = {
62+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
6263
{ 0x0121c0ec, 0xc30c0000, 0x7d57fab0, 0x49270938 }, /* Deflate header for 0x00 */
6364
{ 0x0121c0ec, 0xc30c0000, 0x7baaff30, 0x49270938 } /* Deflate header for 0xFF */
65+
#else
66+
{ 0xecc02101, 0x00000cc3, 0xb0fa577d, 0x38092749 }, /* Deflate header for 0x00 */
67+
{ 0xecc02101, 0x00000cc3, 0x30ffaa7b, 0x38092749 }, /* Deflate header for 0xFF */
68+
#endif
6469

6570
};
6671

0 commit comments

Comments
 (0)