nihav_core/deflate: recognize deflated stream header in uncompress()
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 25 Jun 2020 09:35:49 +0000 (11:35 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 25 Jun 2020 09:35:49 +0000 (11:35 +0200)
nihav-core/src/compr/deflate.rs

index 89e8b6874ea4ae71005f8130fd92818697bb76eb..fa318a473e84647e9ca281cfa6fc868c243c812a 100644 (file)
@@ -716,7 +716,8 @@ 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();
-        inflate.decompress_data(src, dst, false)
+        let off = if src.len() > 2 && src[0] == 0x78 && src[1] == 0x9C { 2 } else { 0 };
+        inflate.decompress_data(&src[off..], dst, false)
     }
 }