Find zip file end of central directory backwards up to max possible size (resubmit...
authorCarlos Sanchez Lopez <1175054+carlossanlop@users.noreply.github.com>
Tue, 1 Oct 2019 16:10:58 +0000 (09:10 -0700)
committerGitHub <noreply@github.com>
Tue, 1 Oct 2019 16:10:58 +0000 (09:10 -0700)
commitd8cfb1a89bbf2e40d0db0dbe1264167f8165554d
tree962dbe603a3c345ba22b28829890ebb4c68780ca
parent0628438acb2d0088fde79b05ba53d7e940852278
Find zip file end of central directory backwards up to max possible size (resubmit due to build break) (dotnet/corefx#41451)

Issue
Huge zip files without an end of central directory take a long time to throw because we seek to the end then search backwards for the EOCD signature all the way to the end.

Fix
Ensure we only search for the signature from the end within the maximum possible number of bytes where it can be found. If the signature is not found, we fail faster.
Submitting again due to build break caused by a conflict in the files modified by this commit.

Note
This may be a breaking change for the edge case where a zip file contains an EOCD comment with the maximum length + additional trailing garbage.

Commit migrated from https://github.com/dotnet/corefx/commit/861259bf87d8e4ee2c4f8dab31b73d377faff77d
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipBlocks.cs
src/libraries/System.IO.Compression/src/System/IO/Compression/ZipHelper.cs
src/libraries/System.IO.Compression/tests/ZipArchive/zip_InvalidParametersAndStrangeFiles.cs