From d5d5963c3dc8356de8fdd7eafad3aabd3a9705e9 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Tue, 18 May 2021 18:16:48 +0200 Subject: [PATCH] deflate: fix zlib stream magic detection --- nihav-core/src/compr/deflate.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) } } -- 2.39.5