From 0b122fa05c70a5a8a4ae5ecc9dce96de67528e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Marcos?= Date: Sun, 20 Apr 2025 13:09:48 -0300 Subject: [PATCH] Fix `.zip` crash when file mode isn't present (#804) --- CHANGELOG.md | 3 +++ src/archive/zip.rs | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd50ea8..e622b9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ Categories Used: ### New Features ### Improvements ### Bug Fixes + +- Fix .zip crash when file mode isn't present [\#804](https://github.com/ouch-org/ouch/pull/804) ([marcospb19](https://github.com/marcospb19)) + ### Tweaks ## [0.6.0](https://github.com/ouch-org/ouch/compare/0.5.1...0.6.0) diff --git a/src/archive/zip.rs b/src/archive/zip.rs index 55de2f4..9beac49 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -85,10 +85,8 @@ where )); } - let mode = file.unix_mode().ok_or_else(|| { - std::io::Error::new(std::io::ErrorKind::InvalidData, "Cannot extract file's mode") - })?; - let is_symlink = (mode & 0o170000) == 0o120000; + let mode = file.unix_mode(); + let is_symlink = mode.is_some_and(|mode| mode & 0o170000 == 0o120000); if is_symlink { let mut target = String::new();