Skip to content

Commit

Permalink
Handle empty archive parsing
Browse files Browse the repository at this point in the history
It probably doesn't matter in practice, but let's be correct.
  • Loading branch information
kimci86 committed May 17, 2024
1 parent 663d1aa commit 72b2f4a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,12 @@ auto findCentralDirectoryOffset(std::istream& is) -> std::uint64_t

// look for Zip64 end of central directory locator
is.seekg(-40, std::ios::cur);
if (checkSignature(is, Signature::Zip64EocdLocator))
if (is.fail())
{
// Ignore seekg error when file is too small (e.g. an archive with no entry)
is.clear();
}
else if (checkSignature(is, Signature::Zip64EocdLocator))
{
is.seekg(4, std::ios::cur);
const auto zip64EndOfCentralDirectoryOffset = readInt<std::uint64_t>(is);
Expand Down

0 comments on commit 72b2f4a

Please sign in to comment.