Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -659,16 +659,18 @@ encoding: encoding] copy]; if (extraFieldLength > 0) extraField = [[[stream readDataWithCount: extraFieldLength] mutableCopy] autorelease]; - of_zip_archive_entry_extra_field_find(_extraField, + of_zip_archive_entry_extra_field_find(extraField, OF_ZIP_ARCHIVE_ENTRY_EXTRA_FIELD_ZIP64, &ZIP64Size); if (ZIP64Index != OF_NOT_FOUND) { const uint8_t *ZIP64 = [extraField itemAtIndex: ZIP64Index]; + of_range_t range = + of_range(ZIP64Index - 4, ZIP64Size + 4); if (_uncompressedSize == 0xFFFFFFFF) _uncompressedSize = of_zip_archive_read_field64( &ZIP64, &ZIP64Size); if (_compressedSize == 0xFFFFFFFF) @@ -676,16 +678,17 @@ &ZIP64, &ZIP64Size); if (ZIP64Size > 0) @throw [OFInvalidFormatException exception]; - [extraField removeItemsInRange: - of_range(ZIP64Index - 4, ZIP64Size + 4)]; + [extraField removeItemsInRange: range]; } - [extraField makeImmutable]; - _extraField = [extraField copy]; + if ([extraField count] > 0) { + [extraField makeImmutable]; + _extraField = [extraField copy]; + } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; Index: src/OFZIPArchiveEntry.m ================================================================== --- src/OFZIPArchiveEntry.m +++ src/OFZIPArchiveEntry.m @@ -217,16 +217,18 @@ if (fileCommentLength > 0) _fileComment = [[stream readStringWithLength: fileCommentLength encoding: encoding] copy]; - ZIP64Index = of_zip_archive_entry_extra_field_find(_extraField, + ZIP64Index = of_zip_archive_entry_extra_field_find(extraField, OF_ZIP_ARCHIVE_ENTRY_EXTRA_FIELD_ZIP64, &ZIP64Size); if (ZIP64Index != OF_NOT_FOUND) { const uint8_t *ZIP64 = - [_extraField itemAtIndex: ZIP64Index]; + [extraField itemAtIndex: ZIP64Index]; + of_range_t range = + of_range(ZIP64Index - 4, ZIP64Size + 4); if (_uncompressedSize == 0xFFFFFFFF) _uncompressedSize = of_zip_archive_read_field64( &ZIP64, &ZIP64Size); if (_compressedSize == 0xFFFFFFFF) @@ -241,16 +243,17 @@ &ZIP64, &ZIP64Size); if (ZIP64Size > 0 || _localFileHeaderOffset < 0) @throw [OFInvalidFormatException exception]; - [extraField removeItemsInRange: - of_range(ZIP64Index - 4, ZIP64Size + 4)]; + [extraField removeItemsInRange: range]; } - [extraField makeImmutable]; - _extraField = [extraField copy]; + if ([extraField count] > 0) { + [extraField makeImmutable]; + _extraField = [extraField copy]; + } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e;