Merge pull request #391 from ZipArchive/incorrect_headers
compatibility with incorrect headers
This commit is contained in:
commit
b8a68d1a08
@ -234,24 +234,25 @@
|
||||
XCTAssertTrue([fileManager fileExistsAtPath:testPath], @"LICENSE unzipped");
|
||||
}
|
||||
|
||||
//Temp Disabled test, fix is not yet in the AES version of the unzip lib
|
||||
|
||||
//- (void)testUnzippingTruncatedFileFix {
|
||||
// NSString *zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"IncorrectHeaders" ofType:@"zip"];
|
||||
// NSString *outputPath = [self _cachesPath:@"IncorrectHeaders"];
|
||||
//
|
||||
// id<SSZipArchiveDelegate> delegate = [ProgressDelegate new];
|
||||
// BOOL success = [SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:delegate];
|
||||
- (void)testUnzippingTruncatedFileFix {
|
||||
NSString *zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"IncorrectHeaders" ofType:@"zip"];
|
||||
NSString *outputPath = [self _cachesPath:@"IncorrectHeaders"];
|
||||
|
||||
id<SSZipArchiveDelegate> delegate = [ProgressDelegate new];
|
||||
__unused BOOL success = [SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:delegate];
|
||||
// Temp disabled test, it's unclear if it's supposed to be a success of failure
|
||||
// as Z_BUF_ERROR is returned for "__MACOSX/IncorrectHeaders/._Readme.txt"
|
||||
//XCTAssertTrue(success);
|
||||
//
|
||||
// NSString *intendedReadmeTxtMD5 = @"31ac96301302eb388070c827447290b5";
|
||||
//
|
||||
// NSString *filePath = [outputPath stringByAppendingPathComponent:@"IncorrectHeaders/Readme.txt"];
|
||||
// NSData *data = [NSData dataWithContentsOfFile:filePath];
|
||||
//
|
||||
// NSString *actualReadmeTxtMD5 = [self _calculateMD5Digest:data];
|
||||
// XCTAssertTrue([actualReadmeTxtMD5 isEqualToString:intendedReadmeTxtMD5], @"Readme.txt MD5 digest should match original.");
|
||||
//}
|
||||
|
||||
NSString *intendedReadmeTxtMD5 = @"31ac96301302eb388070c827447290b5";
|
||||
|
||||
NSString *filePath = [outputPath stringByAppendingPathComponent:@"IncorrectHeaders/Readme.txt"];
|
||||
NSData *data = [NSData dataWithContentsOfFile:filePath];
|
||||
|
||||
NSString *actualReadmeTxtMD5 = [self _calculateMD5Digest:data];
|
||||
XCTAssertTrue([actualReadmeTxtMD5 isEqualToString:intendedReadmeTxtMD5], @"Readme.txt MD5 digest should match original.");
|
||||
}
|
||||
|
||||
|
||||
- (void)testUnzippingWithSymlinkedFileInside {
|
||||
|
@ -1297,17 +1297,9 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, uint32_t len)
|
||||
s->pfile_in_zip_read->stream.next_out = (uint8_t*)buf;
|
||||
s->pfile_in_zip_read->stream.avail_out = (uint16_t)len;
|
||||
|
||||
if (s->pfile_in_zip_read->raw)
|
||||
{
|
||||
if (len > s->pfile_in_zip_read->rest_read_compressed + s->pfile_in_zip_read->stream.avail_in)
|
||||
s->pfile_in_zip_read->stream.avail_out = (uint16_t)s->pfile_in_zip_read->rest_read_compressed +
|
||||
s->pfile_in_zip_read->stream.avail_in;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (len > s->pfile_in_zip_read->rest_read_uncompressed)
|
||||
s->pfile_in_zip_read->stream.avail_out = (uint16_t)s->pfile_in_zip_read->rest_read_uncompressed;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user