From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/flate2/.cargo-checksum.json | 2 +- vendor/flate2/Cargo.lock | 2 +- vendor/flate2/Cargo.toml | 2 +- vendor/flate2/src/deflate/bufread.rs | 10 ++++--- vendor/flate2/src/deflate/read.rs | 8 ++--- vendor/flate2/src/ffi/c.rs | 12 ++++++++ vendor/flate2/src/gz/bufread.rs | 16 +++++----- vendor/flate2/src/gz/mod.rs | 9 ++++-- vendor/flate2/src/gz/read.rs | 14 ++++----- vendor/flate2/src/mem.rs | 58 ++++++++++++++++++++---------------- vendor/flate2/src/zlib/bufread.rs | 10 ++++--- vendor/flate2/src/zlib/read.rs | 8 ++--- 12 files changed, 91 insertions(+), 60 deletions(-) (limited to 'vendor/flate2') diff --git a/vendor/flate2/.cargo-checksum.json b/vendor/flate2/.cargo-checksum.json index e4f368733..be6b4dd18 100644 --- a/vendor/flate2/.cargo-checksum.json +++ b/vendor/flate2/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"5b74a7b515d919a6daa450d673aca5b4a9e65d78883f4c59bf51ce9b5ac9d2dc","Cargo.toml":"abfa5f6669c976afea17a44d1c9249e0b3db8610322566083f48d4bfe33da10b","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","MAINTENANCE.md":"20ef2cb336c850d849652b110ec4806b71e69ed5dd50518a95eb9d453f8bf645","README.md":"a8fab33160befebe83eece4801f401da5932c0e1cca8e97a7ae4bce4aae1b061","examples/compress_file.rs":"cbdb8b0c556409b82f894ad5326babb6dba42c219d2d675927e7f5820053b295","examples/decompress_file.rs":"cd50dfbaccc905b3e02d6c50b26586196a682880203a8694343e0391799b70d5","examples/deflatedecoder-bufread.rs":"5b8abebce157f9b7cc3f6b5c90b9d533890a514e5f8d91bb43439f52fdc9ddce","examples/deflatedecoder-read.rs":"921e13031c5436494d8af0a8705a0adda2da536edefef2e1e311dffa8acd120f","examples/deflatedecoder-write.rs":"cfce37e8758c6d543dd130c7bdff571af3c8cd11bafcc933740107a3576832df","examples/deflateencoder-bufread.rs":"9fdd7d632d861f099d19a3ec1de539d9600f8004a119dd2a70f6aba5965b2e1c","examples/deflateencoder-read.rs":"8740a942ec7d07ccb4b57c5baac7a4d649817bffe4e37ce9a06c7d6d70378e4c","examples/deflateencoder-write.rs":"8e45425684b2368ef95f3704dce6f8077f38b9a90a38d147594c7c570f0d1c6c","examples/gzbuilder.rs":"d09c83417e4a01a8593ce3462a33340e6fe17fa51b4b0b3a6005b68959df4d8c","examples/gzdecoder-bufread.rs":"76880f3e6e10ed4a0bf564be9ddae1c50811aeabf61fb573039538b81805f390","examples/gzdecoder-read.rs":"d99e9a9ce03a27f280244a24e8f5a3282e5af15b455270d99c4bfecd19238d0d","examples/gzdecoder-write.rs":"d0a982377ca1d2fd1786bb32f16454b4f0afdba5e1c7f0ab97e15e8827d351d5","examples/gzencoder-bufread.rs":"760670c124b1c5776b63c300c7e8a1dcd5e0ae633017dcf2e3d2d6e997dcc9c4","examples/gzencoder-read.rs":"27ec68675418bb7d1a110b8d1f33e7b1069f42bcce6f21f8d9235bde405cdf9f","examples/gzencoder-write.rs":"f127f2e398231d03269770fa18ac5d465f8d56d283f1118055f04f1d03369c31","examples/gzmultidecoder-bufread.rs":"bfa6c5554c3da5a61a7d1e1dad115b7ee784d136e2ac61272c87ad3e1eb4ec4c","examples/gzmultidecoder-read.rs":"c058d5eee5bf45b38132f8e487a714c9521191c7dabe2459362d2f8de689c6bf","examples/hello_world.txt":"d2a84f4b8b650937ec8f73cd8be2c74add5a911ba64df27458ed8229da804a26","examples/hello_world.txt.gz":"8b4c5972b92b8ee8dc99116e278afb9165276ddb13c0d334c8da2770fd4d1f7d","examples/zlibdecoder-bufread.rs":"0f541ec64c635d45fc206a02718c0b90c49123a0441a95455d6a8a9e0d20e011","examples/zlibdecoder-read.rs":"bbd85b47b8b804c3294b3f23f978eaf6fb09a187cb46eb86ae1ae2790dfab8d9","examples/zlibdecoder-write.rs":"f347a831d7201d3efd604b006c88421fa2a5906c6377b47c7ae391d0809186e6","examples/zlibencoder-bufread.rs":"e0e05686ad4521ba18b742a5cbbc5937cec1fd8b9e8313070b32c6f178dfbaf6","examples/zlibencoder-read.rs":"4a3156dc73cd77e6ac56700680652be63a1270d95ce384ebcd5c014cce2d5179","examples/zlibencoder-write.rs":"822d4cd326ac7402ff8f828c1dbb3aa108c68a89fc04488da252ca6a74e624b0","src/bufreader.rs":"2d6a59330e8f838eb6474d19104f21cb98236125c189f36bdff75a069a4cea8f","src/crc.rs":"f02b9ffbedf06360c8164f98ecf51fe7f70c48cdb3bfc72e176421419c1de030","src/deflate/bufread.rs":"76af1e22d74571304f7a632751bf80ad946808ff516138696cc6b3d6c586529b","src/deflate/mod.rs":"d33ef6a3d502d599a4ba6ac99c6312b414002dba43c388d271fc1f8c9c609363","src/deflate/read.rs":"122632aff99207af0d998b0890bad44cbc68bb671dcf086cf35adae847175c66","src/deflate/write.rs":"fef4deebc0dc29d4ad481718613c694f6d1b733199e241a1f7f064e2707e4908","src/ffi/c.rs":"f564f9b27278e770006ffda9b078a6a9f5219ffd3fbbc9e315c27bc134b0c32f","src/ffi/mod.rs":"2b811be787e23654e56a1a5748f64f6b6953a829594aef9bdb8f223fe9a1bba9","src/ffi/rust.rs":"0a69aac9bd08728d212f503a16c0e7fb64a7822a7531bc3a96e78c89c09b6e80","src/gz/bufread.rs":"ff18bb9bb6564e45ee2b6dbf4c9dbfe72b25982cd26748b6121f9cab8a7b0dab","src/gz/mod.rs":"2cbcf00c6372d9dd383197bdeceec80dacc8d73d8d5ff44a05fa88040681c5cb","src/gz/read.rs":"68c79bcd34ff14e7572b2f9862f3fb12a26885986783180b7fdce77ae4fb9260","src/gz/write.rs":"78954929f24229875503ffdc04944924120c199fa502a0742e195cffcc135631","src/lib.rs":"9651a09ff275d464ff4865974797a6dc8f2f786225e159b6bd0dbbfd5afc0cef","src/mem.rs":"e563f95d7ab3343b4c86c968c8810b96d74d8cf7612818dd60cd1f6bc4f63eb3","src/zio.rs":"ed5f375f5d6c4f094dfdd43185c9af5e91d1129bfbfa31edc6902a1f7496920b","src/zlib/bufread.rs":"4ef683b9035720d19eec5f21f46f70b7d8eaf9385caddcfd9e48533c619cbb26","src/zlib/mod.rs":"18ea5785b913d90191c6ad8483f57d0c5f98599137659e72f3c0c78324b4f8fa","src/zlib/read.rs":"7dea75ca1dec5a2175b0f45fb2445a345fbe1d220cf4c599e25dece43c520271","src/zlib/write.rs":"5cb973ffb9fc0e6ee8f3cc4537d0b32f826dbe7c367723752d2db708af8831bb","tests/corrupt-gz-file.bin":"083dd284aa1621916a2d0f66ea048c8d3ba7a722b22d0d618722633f51e7d39c","tests/early-flush.rs":"9a4db8fcbac659c52cafe5e1ab647d86781cf8b1f298d8dee34223c0292e0d74","tests/empty-read.rs":"39143ff0383655bb115e995b2a953f11e82d0ac03b4bec080973be7c2d421054","tests/good-file.gz":"87296963e53024a74752179ce7e54087565d358a85d3e65c3b37ef36eaa3d4a6","tests/good-file.txt":"bc4e03658a441fe2ad2df7cd2197144b87e41696f01e327b380e869cd9b485a0","tests/gunzip.rs":"c00946db2147b23c4300c77fedf0a04e65c774101575e9828433831311416a50","tests/multi.gz":"efa3341da052f95056314cc6920e02a3da15bdef30234b2552fb407812db5cc6","tests/multi.txt":"dbea9325179efe46ea2add94f7b6b745ca983fabb208dc6d34aa064623d7ee23","tests/zero-write.rs":"cde1a675491d88e59a711103d3b0df4c77b60e8152b90d5a4f01b97879f8f8dc"},"package":"c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010"} \ No newline at end of file +{"files":{"Cargo.lock":"2721de22957f2a734adfc7415f27f5219bab8c60dea870f8b1c2dbd30cc46c62","Cargo.toml":"b0c766bc094342b650ce071fe410f4446b6adbe4a776253b2d906ce68393209d","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","MAINTENANCE.md":"20ef2cb336c850d849652b110ec4806b71e69ed5dd50518a95eb9d453f8bf645","README.md":"a8fab33160befebe83eece4801f401da5932c0e1cca8e97a7ae4bce4aae1b061","examples/compress_file.rs":"cbdb8b0c556409b82f894ad5326babb6dba42c219d2d675927e7f5820053b295","examples/decompress_file.rs":"cd50dfbaccc905b3e02d6c50b26586196a682880203a8694343e0391799b70d5","examples/deflatedecoder-bufread.rs":"5b8abebce157f9b7cc3f6b5c90b9d533890a514e5f8d91bb43439f52fdc9ddce","examples/deflatedecoder-read.rs":"921e13031c5436494d8af0a8705a0adda2da536edefef2e1e311dffa8acd120f","examples/deflatedecoder-write.rs":"cfce37e8758c6d543dd130c7bdff571af3c8cd11bafcc933740107a3576832df","examples/deflateencoder-bufread.rs":"9fdd7d632d861f099d19a3ec1de539d9600f8004a119dd2a70f6aba5965b2e1c","examples/deflateencoder-read.rs":"8740a942ec7d07ccb4b57c5baac7a4d649817bffe4e37ce9a06c7d6d70378e4c","examples/deflateencoder-write.rs":"8e45425684b2368ef95f3704dce6f8077f38b9a90a38d147594c7c570f0d1c6c","examples/gzbuilder.rs":"d09c83417e4a01a8593ce3462a33340e6fe17fa51b4b0b3a6005b68959df4d8c","examples/gzdecoder-bufread.rs":"76880f3e6e10ed4a0bf564be9ddae1c50811aeabf61fb573039538b81805f390","examples/gzdecoder-read.rs":"d99e9a9ce03a27f280244a24e8f5a3282e5af15b455270d99c4bfecd19238d0d","examples/gzdecoder-write.rs":"d0a982377ca1d2fd1786bb32f16454b4f0afdba5e1c7f0ab97e15e8827d351d5","examples/gzencoder-bufread.rs":"760670c124b1c5776b63c300c7e8a1dcd5e0ae633017dcf2e3d2d6e997dcc9c4","examples/gzencoder-read.rs":"27ec68675418bb7d1a110b8d1f33e7b1069f42bcce6f21f8d9235bde405cdf9f","examples/gzencoder-write.rs":"f127f2e398231d03269770fa18ac5d465f8d56d283f1118055f04f1d03369c31","examples/gzmultidecoder-bufread.rs":"bfa6c5554c3da5a61a7d1e1dad115b7ee784d136e2ac61272c87ad3e1eb4ec4c","examples/gzmultidecoder-read.rs":"c058d5eee5bf45b38132f8e487a714c9521191c7dabe2459362d2f8de689c6bf","examples/hello_world.txt":"d2a84f4b8b650937ec8f73cd8be2c74add5a911ba64df27458ed8229da804a26","examples/hello_world.txt.gz":"8b4c5972b92b8ee8dc99116e278afb9165276ddb13c0d334c8da2770fd4d1f7d","examples/zlibdecoder-bufread.rs":"0f541ec64c635d45fc206a02718c0b90c49123a0441a95455d6a8a9e0d20e011","examples/zlibdecoder-read.rs":"bbd85b47b8b804c3294b3f23f978eaf6fb09a187cb46eb86ae1ae2790dfab8d9","examples/zlibdecoder-write.rs":"f347a831d7201d3efd604b006c88421fa2a5906c6377b47c7ae391d0809186e6","examples/zlibencoder-bufread.rs":"e0e05686ad4521ba18b742a5cbbc5937cec1fd8b9e8313070b32c6f178dfbaf6","examples/zlibencoder-read.rs":"4a3156dc73cd77e6ac56700680652be63a1270d95ce384ebcd5c014cce2d5179","examples/zlibencoder-write.rs":"822d4cd326ac7402ff8f828c1dbb3aa108c68a89fc04488da252ca6a74e624b0","src/bufreader.rs":"2d6a59330e8f838eb6474d19104f21cb98236125c189f36bdff75a069a4cea8f","src/crc.rs":"f02b9ffbedf06360c8164f98ecf51fe7f70c48cdb3bfc72e176421419c1de030","src/deflate/bufread.rs":"49b3d3414343811f96f2ce66bf4db2cf02770986ac500368722111060c4de8b1","src/deflate/mod.rs":"d33ef6a3d502d599a4ba6ac99c6312b414002dba43c388d271fc1f8c9c609363","src/deflate/read.rs":"57f7a9609a111e88fb079188fdc0a79e1e20d97d363bd133f134ad11049220e0","src/deflate/write.rs":"fef4deebc0dc29d4ad481718613c694f6d1b733199e241a1f7f064e2707e4908","src/ffi/c.rs":"9a5648a29a534945244376777c41f9b4f100679ebc2ba3016c7e698181fb5cbf","src/ffi/mod.rs":"2b811be787e23654e56a1a5748f64f6b6953a829594aef9bdb8f223fe9a1bba9","src/ffi/rust.rs":"0a69aac9bd08728d212f503a16c0e7fb64a7822a7531bc3a96e78c89c09b6e80","src/gz/bufread.rs":"fd87b3600af9f22b52aa5e9e6f5636ade64573042f852158584234c2895b35f7","src/gz/mod.rs":"c3449201bd4bad2e4289f4cd1081a4be4505e7d9e8fee5a2838248bf979ef9f0","src/gz/read.rs":"4956e0dbe921810e88f86623c28c74f62aa3b0f36a4461a9dbaeabb2d77ef5bb","src/gz/write.rs":"78954929f24229875503ffdc04944924120c199fa502a0742e195cffcc135631","src/lib.rs":"9651a09ff275d464ff4865974797a6dc8f2f786225e159b6bd0dbbfd5afc0cef","src/mem.rs":"9ef7db386d178ef6426877d2b459165e42757b17ea01bd750e26b74f5691e97a","src/zio.rs":"ed5f375f5d6c4f094dfdd43185c9af5e91d1129bfbfa31edc6902a1f7496920b","src/zlib/bufread.rs":"9284cb80c00ff8e78f2845c1a2911a99c99745b1558085d5f42e26520ff011be","src/zlib/mod.rs":"18ea5785b913d90191c6ad8483f57d0c5f98599137659e72f3c0c78324b4f8fa","src/zlib/read.rs":"4a06d07ea137390efd823554afed7d05a8acfc3ab4f5a5382202030380281f23","src/zlib/write.rs":"5cb973ffb9fc0e6ee8f3cc4537d0b32f826dbe7c367723752d2db708af8831bb","tests/corrupt-gz-file.bin":"083dd284aa1621916a2d0f66ea048c8d3ba7a722b22d0d618722633f51e7d39c","tests/early-flush.rs":"9a4db8fcbac659c52cafe5e1ab647d86781cf8b1f298d8dee34223c0292e0d74","tests/empty-read.rs":"39143ff0383655bb115e995b2a953f11e82d0ac03b4bec080973be7c2d421054","tests/good-file.gz":"87296963e53024a74752179ce7e54087565d358a85d3e65c3b37ef36eaa3d4a6","tests/good-file.txt":"bc4e03658a441fe2ad2df7cd2197144b87e41696f01e327b380e869cd9b485a0","tests/gunzip.rs":"c00946db2147b23c4300c77fedf0a04e65c774101575e9828433831311416a50","tests/multi.gz":"efa3341da052f95056314cc6920e02a3da15bdef30234b2552fb407812db5cc6","tests/multi.txt":"dbea9325179efe46ea2add94f7b6b745ca983fabb208dc6d34aa064623d7ee23","tests/zero-write.rs":"cde1a675491d88e59a711103d3b0df4c77b60e8152b90d5a4f01b97879f8f8dc"},"package":"46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"} \ No newline at end of file diff --git a/vendor/flate2/Cargo.lock b/vendor/flate2/Cargo.lock index f4aa76087..ee16dc6a5 100644 --- a/vendor/flate2/Cargo.lock +++ b/vendor/flate2/Cargo.lock @@ -49,7 +49,7 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" dependencies = [ "cloudflare-zlib-sys", "crc32fast", diff --git a/vendor/flate2/Cargo.toml b/vendor/flate2/Cargo.toml index f37e09968..c7b2e8373 100644 --- a/vendor/flate2/Cargo.toml +++ b/vendor/flate2/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2018" name = "flate2" -version = "1.0.27" +version = "1.0.28" authors = [ "Alex Crichton ", "Josh Triplett ", diff --git a/vendor/flate2/src/deflate/bufread.rs b/vendor/flate2/src/deflate/bufread.rs index e375952d0..c70a63031 100644 --- a/vendor/flate2/src/deflate/bufread.rs +++ b/vendor/flate2/src/deflate/bufread.rs @@ -7,9 +7,10 @@ use crate::{Compress, Decompress}; /// A DEFLATE encoder, or compressor. /// -/// This structure consumes a [`BufRead`] interface, reading uncompressed data -/// from the underlying reader, and emitting compressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// uncompressed data from the underlying [`BufRead`] and provides the compressed data. /// +/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html /// /// # Examples @@ -123,9 +124,10 @@ impl Write for DeflateEncoder { /// A DEFLATE decoder, or decompressor. /// -/// This structure consumes a [`BufRead`] interface, reading compressed data -/// from the underlying reader, and emitting uncompressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// compressed data from the underlying [`BufRead`] and provides the uncompressed data. /// +/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html /// /// # Examples diff --git a/vendor/flate2/src/deflate/read.rs b/vendor/flate2/src/deflate/read.rs index 5937e6f64..2b6b8f2f7 100644 --- a/vendor/flate2/src/deflate/read.rs +++ b/vendor/flate2/src/deflate/read.rs @@ -6,8 +6,8 @@ use crate::bufreader::BufReader; /// A DEFLATE encoder, or compressor. /// -/// This structure implements a [`Read`] interface and will read uncompressed -/// data from an underlying stream and emit a stream of compressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// uncompressed data from the underlying [`Read`] and provides the compressed data. /// /// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// @@ -120,8 +120,8 @@ impl Write for DeflateEncoder { /// A DEFLATE decoder, or decompressor. /// -/// This structure implements a [`Read`] interface and takes a stream of -/// compressed data as input, providing the decompressed data when read from. +/// This structure implements a [`Read`] interface. When read from, it reads +/// compressed data from the underlying [`Read`] and provides the uncompressed data. /// /// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// diff --git a/vendor/flate2/src/ffi/c.rs b/vendor/flate2/src/ffi/c.rs index 48acd438c..32864f8f9 100644 --- a/vendor/flate2/src/ffi/c.rs +++ b/vendor/flate2/src/ffi/c.rs @@ -226,6 +226,12 @@ impl InflateBackend for Inflate { self.inner.total_in += (raw.next_in as usize - input.as_ptr() as usize) as u64; self.inner.total_out += (raw.next_out as usize - output.as_ptr() as usize) as u64; + // reset these pointers so we don't accidentally read them later + raw.next_in = ptr::null_mut(); + raw.avail_in = 0; + raw.next_out = ptr::null_mut(); + raw.avail_out = 0; + match rc { MZ_DATA_ERROR | MZ_STREAM_ERROR => mem::decompress_failed(self.inner.msg()), MZ_OK => Ok(Status::Ok), @@ -314,6 +320,12 @@ impl DeflateBackend for Deflate { self.inner.total_in += (raw.next_in as usize - input.as_ptr() as usize) as u64; self.inner.total_out += (raw.next_out as usize - output.as_ptr() as usize) as u64; + // reset these pointers so we don't accidentally read them later + raw.next_in = ptr::null_mut(); + raw.avail_in = 0; + raw.next_out = ptr::null_mut(); + raw.avail_out = 0; + match rc { MZ_OK => Ok(Status::Ok), MZ_BUF_ERROR => Ok(Status::BufError), diff --git a/vendor/flate2/src/gz/bufread.rs b/vendor/flate2/src/gz/bufread.rs index 6fc48bcdd..679b4a7de 100644 --- a/vendor/flate2/src/gz/bufread.rs +++ b/vendor/flate2/src/gz/bufread.rs @@ -19,10 +19,10 @@ fn copy(into: &mut [u8], from: &[u8], pos: &mut usize) -> usize { /// A gzip streaming encoder /// -/// This structure exposes a [`BufRead`] interface that will read uncompressed data -/// from the underlying reader and expose the compressed version as a [`BufRead`] -/// interface. +/// This structure implements a [`Read`] interface. When read from, it reads +/// uncompressed data from the underlying [`BufRead`] and provides the compressed data. /// +/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html /// /// # Examples @@ -165,8 +165,8 @@ impl Write for GzEncoder { /// A decoder for a single member of a [gzip file]. /// -/// This structure exposes a [`BufRead`] interface, reading compressed data -/// from the underlying reader, and emitting uncompressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// compressed data from the underlying [`BufRead`] and provides the uncompressed data. /// /// After reading a single member of the gzip data this reader will return /// Ok(0) even if there are more bytes available in the underlying reader. @@ -178,6 +178,7 @@ impl Write for GzEncoder { /// [in the introduction](../index.html#about-multi-member-gzip-files). /// /// [gzip file]: https://www.rfc-editor.org/rfc/rfc1952#page-5 +/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html /// /// # Examples @@ -351,8 +352,8 @@ impl Write for GzDecoder { /// A gzip streaming decoder that decodes a [gzip file] that may have multiple members. /// -/// This structure exposes a [`BufRead`] interface that will consume compressed -/// data from the underlying reader and emit uncompressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// compressed data from the underlying [`BufRead`] and provides the uncompressed data. /// /// A gzip file consists of a series of *members* concatenated one after another. /// MultiGzDecoder decodes all members from the data and only returns Ok(0) when the @@ -362,6 +363,7 @@ impl Write for GzDecoder { /// [in the introduction](../index.html#about-multi-member-gzip-files). /// /// [gzip file]: https://www.rfc-editor.org/rfc/rfc1952#page-5 +/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html /// /// # Examples diff --git a/vendor/flate2/src/gz/mod.rs b/vendor/flate2/src/gz/mod.rs index e8e05c6eb..31a696116 100644 --- a/vendor/flate2/src/gz/mod.rs +++ b/vendor/flate2/src/gz/mod.rs @@ -87,7 +87,7 @@ impl GzHeader { } } -#[derive(Debug, Default)] +#[derive(Debug)] pub enum GzHeaderState { Start(u8, [u8; 10]), Xlen(Option>, u8, [u8; 2]), @@ -95,10 +95,15 @@ pub enum GzHeaderState { Filename(Option>), Comment(Option>), Crc(Option>, u8, [u8; 2]), - #[default] Complete, } +impl Default for GzHeaderState { + fn default() -> Self { + Self::Complete + } +} + #[derive(Debug, Default)] pub struct GzHeaderParser { state: GzHeaderState, diff --git a/vendor/flate2/src/gz/read.rs b/vendor/flate2/src/gz/read.rs index 5a65526ce..9dbadbda7 100644 --- a/vendor/flate2/src/gz/read.rs +++ b/vendor/flate2/src/gz/read.rs @@ -8,9 +8,8 @@ use crate::Compression; /// A gzip streaming encoder /// -/// This structure exposes a [`Read`] interface that will read uncompressed data -/// from the underlying reader and expose the compressed version as a [`Read`] -/// interface. +/// This structure implements a [`Read`] interface. When read from, it reads +/// uncompressed data from the underlying [`Read`] and provides the compressed data. /// /// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// @@ -92,8 +91,8 @@ impl Write for GzEncoder { /// A decoder for a single member of a [gzip file]. /// -/// This structure exposes a [`Read`] interface that will consume compressed -/// data from the underlying reader and emit uncompressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// compressed data from the underlying [`Read`] and provides the uncompressed data. /// /// After reading a single member of the gzip data this reader will return /// Ok(0) even if there are more bytes available in the underlying reader. @@ -201,8 +200,9 @@ impl Write for GzDecoder { /// A gzip streaming decoder that decodes a [gzip file] that may have multiple members. /// -/// This structure exposes a [`Read`] interface that will consume compressed -/// data from the underlying reader and emit uncompressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// compressed data from the underlying [`Read`] and provides the uncompressed +/// data. /// /// A gzip file consists of a series of *members* concatenated one after another. /// MultiGzDecoder decodes all members of a file and returns Ok(0) once the diff --git a/vendor/flate2/src/mem.rs b/vendor/flate2/src/mem.rs index 6313c220d..d4a509179 100644 --- a/vendor/flate2/src/mem.rs +++ b/vendor/flate2/src/mem.rs @@ -1,7 +1,6 @@ use std::error::Error; use std::fmt; use std::io; -use std::slice; use crate::ffi::{self, Backend, Deflate, DeflateBackend, ErrorMessage, Inflate, InflateBackend}; use crate::Compression; @@ -342,19 +341,12 @@ impl Compress { output: &mut Vec, flush: FlushCompress, ) -> Result { - let cap = output.capacity(); - let len = output.len(); - - unsafe { + write_to_spare_capacity_of_vec(output, |out| { let before = self.total_out(); - let ret = { - let ptr = output.as_mut_ptr().add(len); - let out = slice::from_raw_parts_mut(ptr, cap - len); - self.compress(input, out, flush) - }; - output.set_len((self.total_out() - before) as usize + len); - ret - } + let ret = self.compress(input, out, flush); + let bytes_written = self.total_out() - before; + (bytes_written as usize, ret) + }) } } @@ -473,19 +465,12 @@ impl Decompress { output: &mut Vec, flush: FlushDecompress, ) -> Result { - let cap = output.capacity(); - let len = output.len(); - - unsafe { + write_to_spare_capacity_of_vec(output, |out| { let before = self.total_out(); - let ret = { - let ptr = output.as_mut_ptr().add(len); - let out = slice::from_raw_parts_mut(ptr, cap - len); - self.decompress(input, out, flush) - }; - output.set_len((self.total_out() - before) as usize + len); - ret - } + let ret = self.decompress(input, out, flush); + let bytes_written = self.total_out() - before; + (bytes_written as usize, ret) + }) } /// Specifies the decompression dictionary to use. @@ -574,6 +559,29 @@ impl fmt::Display for CompressError { } } +/// Allows `writer` to write data into the spare capacity of the `output` vector. +/// This will not reallocate the vector provided or attempt to grow it, so space +/// for the `output` must be reserved by the caller before calling this +/// function. +/// +/// `writer` needs to return the number of bytes written (and can also return +/// another arbitrary return value). +fn write_to_spare_capacity_of_vec( + output: &mut Vec, + writer: impl FnOnce(&mut [u8]) -> (usize, T), +) -> T { + let cap = output.capacity(); + let len = output.len(); + + output.resize(output.capacity(), 0); + let (bytes_written, ret) = writer(&mut output[len..]); + + let new_len = core::cmp::min(len + bytes_written, cap); // Sanitizes `bytes_written`. + output.resize(new_len, 0 /* unused */); + + ret +} + #[cfg(test)] mod tests { use std::io::Write; diff --git a/vendor/flate2/src/zlib/bufread.rs b/vendor/flate2/src/zlib/bufread.rs index aa8af64f8..85bbd38a6 100644 --- a/vendor/flate2/src/zlib/bufread.rs +++ b/vendor/flate2/src/zlib/bufread.rs @@ -7,9 +7,10 @@ use crate::{Compress, Decompress}; /// A ZLIB encoder, or compressor. /// -/// This structure consumes a [`BufRead`] interface, reading uncompressed data -/// from the underlying reader, and emitting compressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// uncompressed data from the underlying [`BufRead`] and provides the compressed data. /// +/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html /// /// # Examples @@ -128,9 +129,10 @@ impl Write for ZlibEncoder { /// A ZLIB decoder, or decompressor. /// -/// This structure consumes a [`BufRead`] interface, reading compressed data -/// from the underlying reader, and emitting uncompressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// compressed data from the underlying [`BufRead`] and provides the uncompressed data. /// +/// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// [`BufRead`]: https://doc.rust-lang.org/std/io/trait.BufRead.html /// /// # Examples diff --git a/vendor/flate2/src/zlib/read.rs b/vendor/flate2/src/zlib/read.rs index fbae74867..3b41ae6c1 100644 --- a/vendor/flate2/src/zlib/read.rs +++ b/vendor/flate2/src/zlib/read.rs @@ -7,8 +7,8 @@ use crate::Decompress; /// A ZLIB encoder, or compressor. /// -/// This structure implements a [`Read`] interface and will read uncompressed -/// data from an underlying stream and emit a stream of compressed data. +/// This structure implements a [`Read`] interface. When read from, it reads +/// uncompressed data from the underlying [`Read`] and provides the compressed data. /// /// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// @@ -126,8 +126,8 @@ impl Write for ZlibEncoder { /// A ZLIB decoder, or decompressor. /// -/// This structure implements a [`Read`] interface and takes a stream of -/// compressed data as input, providing the decompressed data when read from. +/// This structure implements a [`Read`] interface. When read from, it reads +/// compressed data from the underlying [`Read`] and provides the uncompressed data. /// /// [`Read`]: https://doc.rust-lang.org/std/io/trait.Read.html /// -- cgit v1.2.3