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/fuzz/corpus/seed/short_read.zip b/fuzz/corpus/seed/short_read.zip new file mode 100644 index 00000000..e69de29b diff --git a/src/build.rs b/src/build.rs new file mode 100644 index 00000000..8ec1aeab --- /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`"); + } +} 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) } }