deflate: fix zlib stream magic detection
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 18 May 2021 16:16:48 +0000 (18:16 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 18 May 2021 16:16:48 +0000 (18:16 +0200)
nihav-core/src/compr/deflate.rs

index 3462a4034996445255b9ad0f93f79671fae12e9e..638e110b8e4d4bb709712a169c925d7b15366e56 100644 (file)
@@ -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<usize> {
         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)
     }
 }