Merge "Permit 65535 byte ZIP comments and empty Central Directory" am: f420b91e26

am: be81b50b6e

Change-Id: I1275903e7fda6bdd9c1012bc7cfb6c42f6b43304
This commit is contained in:
Alex Klyubin
2016-12-20 20:45:59 +00:00
committed by android-build-merger
2 changed files with 2 additions and 2 deletions

View File

@@ -579,7 +579,7 @@ public class ApkSignatureSchemeV2Verifier {
throws SignatureNotFoundException {
// Look up the offset of ZIP Central Directory.
long centralDirOffset = ZipUtils.getZipEocdCentralDirectoryOffset(eocd);
if (centralDirOffset >= eocdOffset) {
if (centralDirOffset > eocdOffset) {
throw new SignatureNotFoundException(
"ZIP Central Directory offset out of range: " + centralDirOffset
+ ". ZIP End of Central Directory offset: " + eocdOffset);

View File

@@ -160,7 +160,7 @@ abstract class ZipUtils {
}
int maxCommentLength = Math.min(archiveSize - ZIP_EOCD_REC_MIN_SIZE, UINT16_MAX_VALUE);
int eocdWithEmptyCommentStartPosition = archiveSize - ZIP_EOCD_REC_MIN_SIZE;
for (int expectedCommentLength = 0; expectedCommentLength < maxCommentLength;
for (int expectedCommentLength = 0; expectedCommentLength <= maxCommentLength;
expectedCommentLength++) {
int eocdStartPos = eocdWithEmptyCommentStartPosition - expectedCommentLength;
if (zipContents.getInt(eocdStartPos) == ZIP_EOCD_REC_SIG) {