Skip to content

Commit

Permalink
Handle invalid zip header
Browse files Browse the repository at this point in the history
  • Loading branch information
anvie authored Dec 3, 2017
1 parent cb5a919 commit c99d7c2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ impl CentralDirectoryEnd

let search_upper_bound = file_length.checked_sub(HEADER_SIZE + ::std::u16::MAX as u64).unwrap_or(0);

if file_length < HEADER_SIZE {
return Err(ZipError::InvalidArchive("Invalid zip header"));
}

let mut pos = file_length - HEADER_SIZE;
while pos >= search_upper_bound
{
Expand Down

0 comments on commit c99d7c2

Please sign in to comment.