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.
This commit is contained in:
Mathijs van de Nes 2018-10-17 11:45:41 +02:00
parent 9065122b93
commit bb38674a14

View file

@ -331,14 +331,11 @@ fn central_header_to_zip_file<R: Read+io::Seek>(reader: &mut R, archive_offset:
let _disk_number = reader.read_u16::<LittleEndian>()?;
let _internal_file_attributes = reader.read_u16::<LittleEndian>()?;
let external_file_attributes = reader.read_u32::<LittleEndian>()?;
let mut offset = reader.read_u32::<LittleEndian>()? as u64;
let offset = reader.read_u32::<LittleEndian>()? 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<R: Read+io::Seek>(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))?;