From bb38674a147703671adefab23d2b695da4016e69 Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Wed, 17 Oct 2018 11:45:41 +0200 Subject: [PATCH] Add archive_offset after processing extra fields This ensures that the value will still be 0xFFFFFFFF before parsing a zip64 extra field, and that the correction will also apply after the parsing. --- src/read.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/read.rs b/src/read.rs index adcdc8e8..de614eb0 100644 --- a/src/read.rs +++ b/src/read.rs @@ -331,14 +331,11 @@ fn central_header_to_zip_file(reader: &mut R, archive_offset: let _disk_number = reader.read_u16::()?; let _internal_file_attributes = reader.read_u16::()?; let external_file_attributes = reader.read_u32::()?; - let mut offset = reader.read_u32::()? as u64; + let offset = reader.read_u32::()? as u64; let file_name_raw = ReadPodExt::read_exact(reader, file_name_length)?; let extra_field = ReadPodExt::read_exact(reader, extra_field_length)?; let file_comment_raw = ReadPodExt::read_exact(reader, file_comment_length)?; - // Account for shifted zip offsets. - offset += archive_offset; - let file_name = match is_utf8 { true => String::from_utf8_lossy(&*file_name_raw).into_owned(), @@ -374,6 +371,9 @@ fn central_header_to_zip_file(reader: &mut R, archive_offset: Err(e) => Err(e)?, } + // Account for shifted zip offsets. + result.header_start += archive_offset; + // Remember end of central header let return_position = reader.seek(io::SeekFrom::Current(0))?;