Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

fix: add header offset overflow check #259

Merged
merged 2 commits into from
Jan 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: add header offset overflow check
- during the header offset calculation, perform overflow check

Tested:
- Local tests
  • Loading branch information
zamazan4ik committed Jan 22, 2022
commit 8a666b102b0d61b6f76a374f13494c662ae126ef
5 changes: 4 additions & 1 deletion src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,10 @@ pub(crate) fn central_header_to_zip_file<R: Read + io::Seek>(
}

// Account for shifted zip offsets.
result.header_start += archive_offset;
result.header_start = result
.header_start
.checked_add(archive_offset)
.ok_or(ZipError::InvalidArchive("Archive header is too large"))?;

Ok(result)
}
Expand Down