diff options
Diffstat (limited to 'vendor/miniz_oxide')
-rw-r--r-- | vendor/miniz_oxide/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/miniz_oxide/Cargo.toml | 2 | ||||
-rw-r--r-- | vendor/miniz_oxide/Readme.md | 2 | ||||
-rw-r--r-- | vendor/miniz_oxide/src/deflate/core.rs | 1 | ||||
-rw-r--r-- | vendor/miniz_oxide/src/inflate/core.rs | 96 | ||||
-rw-r--r-- | vendor/miniz_oxide/src/lib.rs | 7 |
6 files changed, 84 insertions, 26 deletions
diff --git a/vendor/miniz_oxide/.cargo-checksum.json b/vendor/miniz_oxide/.cargo-checksum.json index e237f121c..0490f2e21 100644 --- a/vendor/miniz_oxide/.cargo-checksum.json +++ b/vendor/miniz_oxide/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"1a05b1f1b1cee9093e2d261931b86dcd92057289d5d8cd675381df52e029c797","LICENSE":"e190940e8ad3cdd4fca962a6508ed6865d589d314b1cb055f86000e124b88d8d","LICENSE-APACHE.md":"0d542e0c8804e39aa7f37eb00da5a762149dc682d7829451287e11b938e94594","LICENSE-MIT.md":"e190940e8ad3cdd4fca962a6508ed6865d589d314b1cb055f86000e124b88d8d","LICENSE-ZLIB.md":"c89bcc058da12a0fb24402b8ea4542a21515dd1da2e8c67bba4ed9bd269f1c96","Readme.md":"d9ae0e4192de8809293672397459f90bdb3cc6a6bd92f235edafbb0530181efb","src/deflate/buffer.rs":"76bcca4e79bef412eeebdd06d2d0a4348ed9ee17edbdaa6d451d8bf03b1cde85","src/deflate/core.rs":"8087c155cb47f57a9747565857dcef59fff0a7a499abbfdb0c60e694d3234db8","src/deflate/mod.rs":"8ade5b9683b8d728fe5e8f5c23e0630165bfdbef3e56a18b1b729f9bbd4a4b1d","src/deflate/stream.rs":"016c82b09a989492c8c8ea89027d339fcf59a5ca2155e7026ac094ca74344712","src/inflate/core.rs":"e7b8946db6a56834311b382fa1f8a3aba21a9ca42cf880c4ae1c97f699d22092","src/inflate/mod.rs":"6a6f658cd44c47f1ba402328fb78c27b24b8700a909ddac4c0c472b12046d1fa","src/inflate/output_buffer.rs":"1ae90d03ba8c9d667fe248b6066731774afdf93cc79cd3bf90e0711b963b0b72","src/inflate/stream.rs":"b1d96270d89b549bdc09352bfbd5a4fea24b479c0057c1f50b66b30ce2eb9cc1","src/lib.rs":"7cb7c0ebc61141f0e43a6edca97a22c93ca3b1550893007359007d4dfdeaa883","src/shared.rs":"a8c47fcb566591e39fcd50d44f3b4d0f567318b8ca36c8d732ee0d8c99a14906"},"package":"b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"}
\ No newline at end of file +{"files":{"Cargo.toml":"e63f554c89c275682109d3b6eb5f1597de27dc3cf2517944974c720f246ac1d7","LICENSE":"e190940e8ad3cdd4fca962a6508ed6865d589d314b1cb055f86000e124b88d8d","LICENSE-APACHE.md":"0d542e0c8804e39aa7f37eb00da5a762149dc682d7829451287e11b938e94594","LICENSE-MIT.md":"e190940e8ad3cdd4fca962a6508ed6865d589d314b1cb055f86000e124b88d8d","LICENSE-ZLIB.md":"c89bcc058da12a0fb24402b8ea4542a21515dd1da2e8c67bba4ed9bd269f1c96","Readme.md":"ab18cf701392873b1f7931909c659915dec0fe8b37ddad50b7cbbc678ebf47e6","src/deflate/buffer.rs":"76bcca4e79bef412eeebdd06d2d0a4348ed9ee17edbdaa6d451d8bf03b1cde85","src/deflate/core.rs":"428abdd660bcce43de28e5d82a1082cc8f88105c882038e6041a3fdffc207121","src/deflate/mod.rs":"8ade5b9683b8d728fe5e8f5c23e0630165bfdbef3e56a18b1b729f9bbd4a4b1d","src/deflate/stream.rs":"016c82b09a989492c8c8ea89027d339fcf59a5ca2155e7026ac094ca74344712","src/inflate/core.rs":"d326880ca0c2ecfdf706839a3e94820e71000dc431d97e4b7d4c2eb3ab6f8cc0","src/inflate/mod.rs":"6a6f658cd44c47f1ba402328fb78c27b24b8700a909ddac4c0c472b12046d1fa","src/inflate/output_buffer.rs":"1ae90d03ba8c9d667fe248b6066731774afdf93cc79cd3bf90e0711b963b0b72","src/inflate/stream.rs":"b1d96270d89b549bdc09352bfbd5a4fea24b479c0057c1f50b66b30ce2eb9cc1","src/lib.rs":"b0be6fbe7198abffe5155984389817219181acabcb9ec2f501baedc6c10797c4","src/shared.rs":"a8c47fcb566591e39fcd50d44f3b4d0f567318b8ca36c8d732ee0d8c99a14906"},"package":"e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"}
\ No newline at end of file diff --git a/vendor/miniz_oxide/Cargo.toml b/vendor/miniz_oxide/Cargo.toml index bbb3e9adb..34a8f9acb 100644 --- a/vendor/miniz_oxide/Cargo.toml +++ b/vendor/miniz_oxide/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2018" name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" authors = [ "Frommi <daniil.liferenko@gmail.com>", "oyvindln <oyvindln@users.noreply.github.com>", diff --git a/vendor/miniz_oxide/Readme.md b/vendor/miniz_oxide/Readme.md index 51579f071..62687c94f 100644 --- a/vendor/miniz_oxide/Readme.md +++ b/vendor/miniz_oxide/Readme.md @@ -11,7 +11,7 @@ Using the library with `default-features = false` removes the dependency on `all and `collection` crates, making it suitable for systems without an allocator. Running without allocation reduces crate functionality: -- The `deflate` module is removed complete +- The `deflate` module is removed completely - Some `inflate` functions which return a `Vec` are removed miniz_oxide 0.5.x and 0.6.x Requires at least rust 1.40.0 0.3.x requires at least rust 0.36.0. diff --git a/vendor/miniz_oxide/src/deflate/core.rs b/vendor/miniz_oxide/src/deflate/core.rs index 91a9bf8b8..d2db26006 100644 --- a/vendor/miniz_oxide/src/deflate/core.rs +++ b/vendor/miniz_oxide/src/deflate/core.rs @@ -517,7 +517,6 @@ impl CompressorOxide { impl Default for CompressorOxide { /// Initialize the compressor with a level of 4, zlib wrapper and /// the default strategy. - #[inline(always)] fn default() -> Self { CompressorOxide { lz: LZOxide::new(), diff --git a/vendor/miniz_oxide/src/inflate/core.rs b/vendor/miniz_oxide/src/inflate/core.rs index 630e5e6fd..6db244989 100644 --- a/vendor/miniz_oxide/src/inflate/core.rs +++ b/vendor/miniz_oxide/src/inflate/core.rs @@ -131,7 +131,7 @@ pub mod inflate_flags { /// /// If [`TINFL_FLAG_IGNORE_ADLER32`] is specified, it will override this. /// - /// NOTE: Enabling/disabling this between calls to decompress will result in an incorect + /// NOTE: Enabling/disabling this between calls to decompress will result in an incorrect /// checksum. pub const TINFL_FLAG_COMPUTE_ADLER32: u32 = 8; @@ -261,6 +261,7 @@ impl Default for DecompressorOxide { } #[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[non_exhaustive] enum State { Start = 0, ReadZlibCmf, @@ -292,6 +293,7 @@ enum State { // Failure states. BlockTypeUnexpected, BadCodeSizeSum, + BadDistOrLiteralTableLength, BadTotalSymbols, BadZlibHeader, DistanceOutOfBounds, @@ -307,6 +309,7 @@ impl State { match self { BlockTypeUnexpected => true, BadCodeSizeSum => true, + BadDistOrLiteralTableLength => true, BadTotalSymbols => true, BadZlibHeader => true, DistanceOutOfBounds => true, @@ -669,6 +672,18 @@ fn start_static_table(r: &mut DecompressorOxide) { memset(&mut r.tables[DIST_TABLE].code_size[0..32], 5); } +static REVERSED_BITS_LOOKUP: [u32; 1024] = { + let mut table = [0; 1024]; + + let mut i = 0; + while i < 1024 { + table[i] = (i as u32).reverse_bits(); + i += 1; + } + + table +}; + fn init_tree(r: &mut DecompressorOxide, l: &mut LocalVars) -> Action { loop { let table = &mut r.tables[r.block_type as usize]; @@ -706,10 +721,17 @@ fn init_tree(r: &mut DecompressorOxide, l: &mut LocalVars) -> Action { let mut cur_code = next_code[code_size as usize]; next_code[code_size as usize] += 1; - for _ in 0..code_size { - rev_code = (rev_code << 1) | (cur_code & 1); - cur_code >>= 1; - } + let n = cur_code & (u32::MAX >> (32 - code_size)); + + let mut rev_code = if n < 1024 { + REVERSED_BITS_LOOKUP[n as usize] >> (32 - code_size) + } else { + for _ in 0..code_size { + rev_code = (rev_code << 1) | (cur_code & 1); + cur_code >>= 1; + } + rev_code + }; if code_size <= FAST_LOOKUP_BITS { let k = (i16::from(code_size) << 9) | symbol_index as i16; @@ -796,13 +818,38 @@ fn transfer( match_len: usize, out_buf_size_mask: usize, ) { - for _ in 0..match_len >> 2 { - out_slice[out_pos] = out_slice[source_pos & out_buf_size_mask]; - out_slice[out_pos + 1] = out_slice[(source_pos + 1) & out_buf_size_mask]; - out_slice[out_pos + 2] = out_slice[(source_pos + 2) & out_buf_size_mask]; - out_slice[out_pos + 3] = out_slice[(source_pos + 3) & out_buf_size_mask]; - source_pos += 4; - out_pos += 4; + // special case that comes up surprisingly often. in the case that `source_pos` + // is 1 less than `out_pos`, we can say that the entire range will be the same + // value and optimize this to be a simple `memset` + let source_diff = if source_pos > out_pos { + source_pos - out_pos + } else { + out_pos - source_pos + }; + if out_buf_size_mask == usize::MAX && source_diff == 1 && out_pos > source_pos { + let init = out_slice[out_pos - 1]; + let end = (match_len >> 2) * 4 + out_pos; + + out_slice[out_pos..end].fill(init); + out_pos = end; + source_pos = end - 1; + // if the difference between `source_pos` and `out_pos` is greater than 3, we + // can do slightly better than the naive case by copying everything at once + } else if out_buf_size_mask == usize::MAX && source_diff >= 4 && out_pos > source_pos { + for _ in 0..match_len >> 2 { + out_slice.copy_within(source_pos..=source_pos + 3, out_pos); + source_pos += 4; + out_pos += 4; + } + } else { + for _ in 0..match_len >> 2 { + out_slice[out_pos] = out_slice[source_pos & out_buf_size_mask]; + out_slice[out_pos + 1] = out_slice[(source_pos + 1) & out_buf_size_mask]; + out_slice[out_pos + 2] = out_slice[(source_pos + 2) & out_buf_size_mask]; + out_slice[out_pos + 3] = out_slice[(source_pos + 3) & out_buf_size_mask]; + source_pos += 4; + out_pos += 4; + } } match match_len & 3 { @@ -1279,7 +1326,18 @@ pub fn decompress( } else { memset(&mut r.tables[HUFFLEN_TABLE].code_size[..], 0); l.counter = 0; - Action::Jump(ReadHufflenTableCodeSize) + // Check that the litlen and distance are within spec. + // litlen table should be <=286 acc to the RFC and + // additionally zlib rejects dist table sizes larger than 30. + // NOTE this the final sizes after adding back predefined values, not + // raw value in the data. + // See miniz_oxide issue #130 and https://github.com/madler/zlib/issues/82. + if r.table_sizes[LITLEN_TABLE] <= 286 && r.table_sizes[DIST_TABLE] <= 30 { + Action::Jump(ReadHufflenTableCodeSize) + } + else { + Action::Jump(BadDistOrLiteralTableLength) + } } }), @@ -1634,7 +1692,8 @@ pub fn decompress( DoneForever => break TINFLStatus::Done, // Anything else indicates failure. - // BadZlibHeader | BadRawLength | BlockTypeUnexpected | DistanceOutOfBounds | + // BadZlibHeader | BadRawLength | BadDistOrLiteralTableLength | BlockTypeUnexpected | + // DistanceOutOfBounds | // BadTotalSymbols | BadCodeSizeDistPrevLookup | BadCodeSizeSum | InvalidLitlen | // InvalidDist | InvalidCodeLen _ => break TINFLStatus::Failed, @@ -1840,14 +1899,15 @@ mod test { cr( b"M\xff\xffM*\xad\xad\xad\xad\xad\xad\xad\xcd\xcd\xcdM", F, - State::BadTotalSymbols, + State::BadDistOrLiteralTableLength, false, ); + // Bad CLEN (also from inflate library issues) cr( b"\xdd\xff\xff*M\x94ffffffffff", F, - State::BadTotalSymbols, + State::BadDistOrLiteralTableLength, false, ); @@ -1869,9 +1929,9 @@ mod test { // Invalid set of code lengths - TODO Check if this is the correct error for this. c(&[4, 0, 0xfe, 0xff], F, State::BadTotalSymbols); // Invalid repeat in list of code lengths. - // (Try to repeat a non-existant code.) + // (Try to repeat a non-existent code.) c(&[4, 0, 0x24, 0x49, 0], F, State::BadCodeSizeDistPrevLookup); - // Missing end of block code (should we have a separate error for this?) - fails on futher input + // Missing end of block code (should we have a separate error for this?) - fails on further input // c(&[4, 0, 0x24, 0xe9, 0xff, 0x6d], F, State::BadTotalSymbols); // Invalid set of literals/lengths c( diff --git a/vendor/miniz_oxide/src/lib.rs b/vendor/miniz_oxide/src/lib.rs index fd64932b0..0e30dc034 100644 --- a/vendor/miniz_oxide/src/lib.rs +++ b/vendor/miniz_oxide/src/lib.rs @@ -1,8 +1,7 @@ //! A pure rust replacement for the [miniz](https://github.com/richgel999/miniz) //! DEFLATE/zlib encoder/decoder. -//! The plan for this crate is to be used as a back-end for the -//! [flate2](https://github.com/alexcrichton/flate2-rs) crate and eventually remove the -//! need to depend on a C library. +//! Used a rust back-end for the +//! [flate2](https://github.com/alexcrichton/flate2-rs) crate. //! //! # Usage //! ## Simple compression/decompression: @@ -175,7 +174,7 @@ impl DataFormat { /// `Result` alias for all miniz status codes both successful and failed. pub type MZResult = Result<MZStatus, MZError>; -/// A structure containg the result of a call to the inflate or deflate streaming functions. +/// A structure containing the result of a call to the inflate or deflate streaming functions. #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct StreamResult { /// The number of bytes consumed from the input slice. |