From 89b9b668ec74002142f5244cfce1e0b3268f4984 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Sun, 19 May 2024 16:53:56 -0700 Subject: [PATCH] refactor: Reject encrypted and using_data_descriptor files slightly faster in read_zipfile_from_stream --- src/read.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/read.rs b/src/read.rs index d06cf602..24e6fea1 100644 --- a/src/read.rs +++ b/src/read.rs @@ -1361,9 +1361,14 @@ pub fn read_zipfile_from_stream<'a, R: Read>(reader: &'a mut R) -> ZipResult(reader: &'a mut R) -> ZipResult> 8) as u8), version_made_by: version_made_by as u8, - encrypted, - using_data_descriptor, + encrypted: flags & 1 == 1, + using_data_descriptor: false, compression_method, compression_level: None, last_modified_time: DateTime::from_msdos(last_mod_date, last_mod_time), @@ -1421,13 +1426,6 @@ pub fn read_zipfile_from_stream<'a, R: Read>(reader: &'a mut R) -> ZipResult return Err(e), } - if encrypted { - return unsupported_zip_error("Encrypted files are not supported"); - } - if using_data_descriptor { - return unsupported_zip_error("The file length is not available in the local header"); - } - let limit_reader = (reader as &'a mut dyn Read).take(result.compressed_size); let result_crc32 = result.crc32;