From: Kostya Shishkov Date: Tue, 18 May 2021 16:16:48 +0000 (+0200) Subject: deflate: fix zlib stream magic detection X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=d5d5963c3dc8356de8fdd7eafad3aabd3a9705e9;p=nihav.git deflate: fix zlib stream magic detection --- diff --git a/nihav-core/src/compr/deflate.rs b/nihav-core/src/compr/deflate.rs index 3462a40..638e110 100644 --- a/nihav-core/src/compr/deflate.rs +++ b/nihav-core/src/compr/deflate.rs @@ -721,7 +721,7 @@ impl Inflate { ///! Decompresses input data into output returning the uncompressed data length. pub fn uncompress(src: &[u8], dst: &mut [u8]) -> DecompressResult { let mut inflate = Self::new(); - let off = if src.len() > 2 && src[0] == 0x78 && src[1] == 0x9C { 2 } else { 0 }; + let off = if src.len() > 2 && src[0] == 0x78 && (src[1] != 0 && ((src[1] - 1) % 31) == 0) { 2 } else { 0 }; inflate.decompress_data(&src[off..], dst, false) } }