From 122ff1f8cbdc74fe58b69ff0a0e5099bbef53023 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:49:43 -0700 Subject: [PATCH 1/4] build: Emit a warning when deprecated deflate-miniz is used --- Cargo.toml | 1 + src/build.rs | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 src/build.rs diff --git a/Cargo.toml b/Cargo.toml index 1586ef46..b1085f29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ Library to support the reading and writing of zip files. """ edition = "2021" exclude = ["tests/**", "examples/**", ".github/**", "fuzz/**"] +build = "src/build.rs" [workspace.dependencies] time = { version = "0.3.36", default-features = false } diff --git a/src/build.rs b/src/build.rs new file mode 100644 index 00000000..534a9a7d --- /dev/null +++ b/src/build.rs @@ -0,0 +1,7 @@ +use std::env::var; + +fn main() { + if var("CARGO_FEATURE_DEFLATE_MINIZ").is_ok() { + println!("cargo::warning=Feature `deflate-miniz` is deprecated; replace it with `deflate`"); + } +} \ No newline at end of file From 5109cb8553dcc2460240eedae46ad9a13ff699c9 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Mon, 29 Apr 2024 16:59:39 -0700 Subject: [PATCH 2/4] test(fuzz): Add recent fuzz_write failure to fuzz_read corpus (failure actually occurred in read) --- fuzz/corpus/seed/short_read.zip | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 fuzz/corpus/seed/short_read.zip diff --git a/fuzz/corpus/seed/short_read.zip b/fuzz/corpus/seed/short_read.zip new file mode 100644 index 00000000..e69de29b From 9739df01dc6f0bdabc52494bb87881afd60b276f Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:00:11 -0700 Subject: [PATCH 3/4] build: Fix a bug where cargo syntax is different for MSRV below 1.77.0 --- src/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build.rs b/src/build.rs index 534a9a7d..c9feaa0a 100644 --- a/src/build.rs +++ b/src/build.rs @@ -2,6 +2,6 @@ use std::env::var; fn main() { if var("CARGO_FEATURE_DEFLATE_MINIZ").is_ok() { - println!("cargo::warning=Feature `deflate-miniz` is deprecated; replace it with `deflate`"); + println!("cargo:warning=Feature `deflate-miniz` is deprecated; replace it with `deflate`"); } } \ No newline at end of file From 686f6f1abfa8b297386e7f57106ca37a8ee7e404 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Mon, 29 Apr 2024 19:16:31 -0700 Subject: [PATCH 4/4] feat: Improve ErrorKind in ZipError to io::Error conversion (previously https://github.com/zip-rs/zip-old/pull/421) --- src/build.rs | 2 +- src/result.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/build.rs b/src/build.rs index c9feaa0a..8ec1aeab 100644 --- a/src/build.rs +++ b/src/build.rs @@ -4,4 +4,4 @@ fn main() { if var("CARGO_FEATURE_DEFLATE_MINIZ").is_ok() { println!("cargo:warning=Feature `deflate-miniz` is deprecated; replace it with `deflate`"); } -} \ No newline at end of file +} diff --git a/src/result.rs b/src/result.rs index 98d9943d..f2bb4609 100644 --- a/src/result.rs +++ b/src/result.rs @@ -79,7 +79,15 @@ impl ZipError { impl From for io::Error { fn from(err: ZipError) -> io::Error { - io::Error::new(io::ErrorKind::Other, err) + let kind = match &err { + ZipError::Io(err) => err.kind(), + ZipError::InvalidArchive(_) => io::ErrorKind::InvalidData, + ZipError::UnsupportedArchive(_) => io::ErrorKind::Unsupported, + ZipError::FileNotFound => io::ErrorKind::NotFound, + ZipError::InvalidPassword => io::ErrorKind::InvalidInput, + }; + + io::Error::new(kind, err) } }