From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/zip/src/read.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'vendor/zip/src/read.rs') diff --git a/vendor/zip/src/read.rs b/vendor/zip/src/read.rs index 728ddf579..dad20c260 100644 --- a/vendor/zip/src/read.rs +++ b/vendor/zip/src/read.rs @@ -348,7 +348,9 @@ impl ZipArchive { Some(locator64) => { // If we got here, this is indeed a ZIP64 file. - if footer.disk_number as u32 != locator64.disk_with_central_directory { + if !footer.record_too_small() + && footer.disk_number as u32 != locator64.disk_with_central_directory + { return unsupported_zip_error( "Support for multi-disk files is not implemented", ); @@ -401,7 +403,7 @@ impl ZipArchive { pub fn new(mut reader: R) -> ZipResult> { let (footer, cde_start_pos) = spec::CentralDirectoryEnd::find_and_parse(&mut reader)?; - if footer.disk_number != footer.disk_with_central_directory { + if !footer.record_too_small() && footer.disk_number != footer.disk_with_central_directory { return unsupported_zip_error("Support for multi-disk files is not implemented"); } @@ -461,7 +463,7 @@ impl ZipArchive { } else { if let Some(p) = outpath.parent() { if !p.exists() { - fs::create_dir_all(&p)?; + fs::create_dir_all(p)?; } } let mut outfile = fs::File::create(&outpath)?; @@ -681,11 +683,11 @@ pub(crate) fn central_header_to_zip_file( reader.read_exact(&mut file_comment_raw)?; let file_name = match is_utf8 { - true => String::from_utf8_lossy(&*file_name_raw).into_owned(), + true => String::from_utf8_lossy(&file_name_raw).into_owned(), false => file_name_raw.clone().from_cp437(), }; let file_comment = match is_utf8 { - true => String::from_utf8_lossy(&*file_comment_raw).into_owned(), + true => String::from_utf8_lossy(&file_comment_raw).into_owned(), false => file_comment_raw.from_cp437(), }; @@ -920,12 +922,12 @@ impl<'a> ZipFile<'a> { self.data.compression_method } - /// Get the size of the file in the archive + /// Get the size of the file, in bytes, in the archive pub fn compressed_size(&self) -> u64 { self.data.compressed_size } - /// Get the size of the file when uncompressed + /// Get the size of the file, in bytes, when uncompressed pub fn size(&self) -> u64 { self.data.uncompressed_size } @@ -1085,7 +1087,7 @@ pub fn read_zipfile_from_stream<'a, R: io::Read>( reader.read_exact(&mut extra_field)?; let file_name = match is_utf8 { - true => String::from_utf8_lossy(&*file_name_raw).into_owned(), + true => String::from_utf8_lossy(&file_name_raw).into_owned(), false => file_name_raw.clone().from_cp437(), }; @@ -1129,7 +1131,7 @@ pub fn read_zipfile_from_stream<'a, R: io::Read>( return unsupported_zip_error("The file length is not available in the local header"); } - let limit_reader = (reader as &'a mut dyn io::Read).take(result.compressed_size as u64); + let limit_reader = (reader as &'a mut dyn io::Read).take(result.compressed_size); let result_crc32 = result.crc32; let result_compression_method = result.compression_method; -- cgit v1.2.3