Merge "Permit 65535 byte ZIP comments and empty Central Directory"

am: f420b91e26

Change-Id: Ic178cdd9043c171f2f51643212e34b642657abe9
This commit is contained in:
Alex Klyubin
2016-12-20 18:45:57 +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) {