mirror of
https://github.com/cuberite/libdeflate.git
synced 2025-08-04 02:06:31 -04:00
the gzip format uses little endian numbers
This commit is contained in:
parent
0b6d0f41c2
commit
19e1688b86
@ -32,7 +32,7 @@ gzip_compress(struct deflate_compressor *c, const void *in, size_t in_size,
|
||||
/* FLG */
|
||||
*out_next++ = 0;
|
||||
/* MTIME */
|
||||
put_unaligned_u32_be(GZIP_MTIME_UNAVAILABLE, out_next);
|
||||
put_unaligned_u32_le(GZIP_MTIME_UNAVAILABLE, out_next);
|
||||
out_next += 4;
|
||||
/* XFL */
|
||||
xfl = 0;
|
||||
@ -53,11 +53,11 @@ gzip_compress(struct deflate_compressor *c, const void *in, size_t in_size,
|
||||
out_next += deflate_size;
|
||||
|
||||
/* CRC32 */
|
||||
put_unaligned_u32_be(crc32(in, in_size), out_next);
|
||||
put_unaligned_u32_le(crc32(in, in_size), out_next);
|
||||
out_next += 4;
|
||||
|
||||
/* ISIZE */
|
||||
put_unaligned_u32_be(in_size, out_next);
|
||||
put_unaligned_u32_le(in_size, out_next);
|
||||
out_next += 4;
|
||||
|
||||
return out_next - (u8 *)out;
|
||||
|
@ -43,7 +43,7 @@ gzip_decompress(struct deflate_decompressor *d,
|
||||
|
||||
/* Extra field */
|
||||
if (flg & GZIP_FEXTRA) {
|
||||
u16 xlen = get_unaligned_u16_be(in_next);
|
||||
u16 xlen = get_unaligned_u16_le(in_next);
|
||||
in_next += 2;
|
||||
|
||||
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;
|
||||
|
||||
/* 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;
|
||||
in_next += 4;
|
||||
|
||||
/* ISIZE */
|
||||
if ((u32)out_nbytes != get_unaligned_u32_be(in_next))
|
||||
if ((u32)out_nbytes != get_unaligned_u32_le(in_next))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user