the gzip format uses little endian numbers

This commit is contained in:
Eric Biggers 2014-12-30 22:28:08 -06:00
parent 0b6d0f41c2
commit 19e1688b86
2 changed files with 6 additions and 6 deletions

View File

@ -32,7 +32,7 @@ gzip_compress(struct deflate_compressor *c, const void *in, size_t in_size,
/* FLG */ /* FLG */
*out_next++ = 0; *out_next++ = 0;
/* MTIME */ /* MTIME */
put_unaligned_u32_be(GZIP_MTIME_UNAVAILABLE, out_next); put_unaligned_u32_le(GZIP_MTIME_UNAVAILABLE, out_next);
out_next += 4; out_next += 4;
/* XFL */ /* XFL */
xfl = 0; xfl = 0;
@ -53,11 +53,11 @@ gzip_compress(struct deflate_compressor *c, const void *in, size_t in_size,
out_next += deflate_size; out_next += deflate_size;
/* CRC32 */ /* CRC32 */
put_unaligned_u32_be(crc32(in, in_size), out_next); put_unaligned_u32_le(crc32(in, in_size), out_next);
out_next += 4; out_next += 4;
/* ISIZE */ /* ISIZE */
put_unaligned_u32_be(in_size, out_next); put_unaligned_u32_le(in_size, out_next);
out_next += 4; out_next += 4;
return out_next - (u8 *)out; return out_next - (u8 *)out;

View File

@ -43,7 +43,7 @@ gzip_decompress(struct deflate_decompressor *d,
/* Extra field */ /* Extra field */
if (flg & GZIP_FEXTRA) { if (flg & GZIP_FEXTRA) {
u16 xlen = get_unaligned_u16_be(in_next); u16 xlen = get_unaligned_u16_le(in_next);
in_next += 2; in_next += 2;
if (in_end - in_next < (u32)xlen + GZIP_FOOTER_SIZE) if (in_end - in_next < (u32)xlen + GZIP_FOOTER_SIZE)
@ -87,12 +87,12 @@ gzip_decompress(struct deflate_decompressor *d,
in_next = in_end - GZIP_FOOTER_SIZE; in_next = in_end - GZIP_FOOTER_SIZE;
/* CRC32 */ /* CRC32 */
if (crc32(out, out_nbytes) != get_unaligned_u32_be(in_next)) if (crc32(out, out_nbytes) != get_unaligned_u32_le(in_next))
return false; return false;
in_next += 4; in_next += 4;
/* ISIZE */ /* ISIZE */
if ((u32)out_nbytes != get_unaligned_u32_be(in_next)) if ((u32)out_nbytes != get_unaligned_u32_le(in_next))
return false; return false;
return true; return true;