diff --git a/Cargo.toml b/Cargo.toml index 9fc6571b..d59d9176 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zip" -version = "2.1.1" +version = "2.1.2" authors = [ "Mathijs van de Nes ", "Marli Frost ", @@ -30,34 +30,34 @@ aes = { version = "0.8.4", optional = true } bzip2 = { version = "0.4.4", optional = true } chrono = { version = "0.4.38", optional = true } constant_time_eq = { version = "0.3.0", optional = true } -crc32fast = "1.4.0" +crc32fast = "1.4.2" displaydoc = { version = "0.2.4", default-features = false } -flate2 = { version = "1.0.28", default-features = false, optional = true } +flate2 = { version = "1.0.30", default-features = false, optional = true } indexmap = "2" hmac = { version = "0.12.1", optional = true, features = ["reset"] } memchr = "2.7.2" pbkdf2 = { version = "0.12.2", optional = true } rand = { version = "0.8.5", optional = true } sha1 = { version = "0.10.6", optional = true } -thiserror = "1.0.48" +thiserror = "1.0.61" time = { workspace = true, optional = true, features = [ "std", ] } -zeroize = { version = "1.6.0", optional = true, features = ["zeroize_derive"] } +zeroize = { version = "1.8.1", optional = true, features = ["zeroize_derive"] } zstd = { version = "0.13.1", optional = true, default-features = false } zopfli = { version = "0.8.1", optional = true } deflate64 = { version = "0.1.8", optional = true } lzma-rs = { version = "0.3.0", default-features = false, optional = true } [target.'cfg(any(all(target_arch = "arm", target_pointer_width = "32"), target_arch = "mips", target_arch = "powerpc"))'.dependencies] -crossbeam-utils = "0.8.19" +crossbeam-utils = "0.8.20" [target.'cfg(fuzzing)'.dependencies] arbitrary = { version = "1.3.2", features = ["derive"] } [dev-dependencies] bencher = "0.1.5" -getrandom = { version = "0.2.14", features = ["js", "std"] } +getrandom = { version = "0.2.15", features = ["js", "std"] } walkdir = "2.5.0" time = { workspace = true, features = ["formatting", "macros"] } anyhow = "1" diff --git a/examples/write_dir.rs b/examples/write_dir.rs index 5475f7bc..5fe41dc8 100644 --- a/examples/write_dir.rs +++ b/examples/write_dir.rs @@ -42,12 +42,12 @@ fn real_main() -> i32 { let method = match args.compression_method { CompressionMethod::Stored => zip::CompressionMethod::Stored, CompressionMethod::Deflated => { - #[cfg(not(feature = "deflate"))] + #[cfg(not(feature = "deflate-flate2"))] { - println!("The `deflate` feature is not enabled"); + println!("The `deflate-flate2` feature is not enabled"); return 1; } - #[cfg(feature = "deflate")] + #[cfg(feature = "deflate-flate2")] zip::CompressionMethod::Deflated } CompressionMethod::DeflatedZlib => { diff --git a/src/read.rs b/src/read.rs index eb7ad7d9..c04dc660 100644 --- a/src/read.rs +++ b/src/read.rs @@ -24,11 +24,7 @@ use std::ops::Deref; use std::path::{Path, PathBuf}; use std::sync::{Arc, OnceLock}; -#[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng" -))] +#[cfg(feature = "deflate-flate2")] use flate2::read::DeflateDecoder; #[cfg(feature = "deflate64")] diff --git a/src/unstable.rs b/src/unstable.rs index 85f2b396..102c4336 100644 --- a/src/unstable.rs +++ b/src/unstable.rs @@ -43,7 +43,7 @@ pub trait LittleEndianWriteExt: Write { } } -impl LittleEndianWriteExt for W {} +impl LittleEndianWriteExt for W {} /// Helper methods for reading unsigned integers in little-endian form. pub trait LittleEndianReadExt: Read { diff --git a/src/write.rs b/src/write.rs index c5c8798e..151258a8 100644 --- a/src/write.rs +++ b/src/write.rs @@ -27,11 +27,7 @@ use std::mem; use std::str::{from_utf8, Utf8Error}; use std::sync::Arc; -#[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng" -))] +#[cfg(feature = "deflate-flate2")] use flate2::{write::DeflateEncoder, Compression}; #[cfg(feature = "bzip2")] @@ -881,9 +877,12 @@ impl ZipWriter { )); }; if pad_length >= 4 { - // Add an extra field to the extra_data - let pad_body = vec![0; pad_length - 4]; - writer.write_all(b"za").map_err(ZipError::from)?; // 0x617a + // Add an extra field to the extra_data, per APPNOTE 4.6.11 + let mut pad_body = vec![0; pad_length - 4]; + if pad_body.len() >= 2 { + [pad_body[0], pad_body[1]] = options.alignment.to_le_bytes(); + } + writer.write_u16_le(0xa11e)?; writer .write_u16_le(pad_body.len() as u16) .map_err(ZipError::from)?; @@ -1566,11 +1565,7 @@ impl GenericZipWriter { } } - #[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng", - ))] + #[cfg(feature = "deflate-flate2")] { Ok(Box::new(move |bare| { GenericZipWriter::Deflater(DeflateEncoder::new( @@ -1630,11 +1625,7 @@ impl GenericZipWriter { fn switch_to(&mut self, make_new_self: SwitchWriterFunction) -> ZipResult<()> { let bare = match mem::replace(self, Closed) { Storer(w) => w, - #[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng" - ))] + #[cfg(feature = "deflate-flate2")] GenericZipWriter::Deflater(w) => w.finish()?, #[cfg(feature = "deflate-zopfli")] GenericZipWriter::ZopfliDeflater(w) => w.finish()?, @@ -1662,11 +1653,7 @@ impl GenericZipWriter { fn ref_mut(&mut self) -> Option<&mut dyn Write> { match self { Storer(ref mut w) => Some(w as &mut dyn Write), - #[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng" - ))] + #[cfg(feature = "deflate-flate2")] GenericZipWriter::Deflater(ref mut w) => Some(w as &mut dyn Write), #[cfg(feature = "deflate-zopfli")] GenericZipWriter::ZopfliDeflater(w) => Some(w as &mut dyn Write),