29 Commits
0.2.0 ... 0.2.3

Author SHA1 Message Date
Sam Soffes
a311e60107 Version 0.2.3
* Update podspec
* Fix remote
* Bump year
* Release changes since last release
2013-01-29 01:54:19 -05:00
Sam Soffes
69fb8f4a4c Merge pull request #34 from cvisprogrammer/master
added fclose to writeFile
2013-01-18 08:14:24 -08:00
Farooq Ahmad
1d163e4db5 Added fclose to writeFile
need fclose to avoid running out of file handles
2012-11-28 09:16:10 -08:00
Sam Soffes
3f5a7b30dc Merge pull request #28 from nivektric/master
Change clean_path to preserve_paths in podspec to pass validation
2012-07-10 12:01:07 -07:00
Kevin Monahan
bdbab4d3b3 Change clean_path to preserve_paths in podspec to pass validation 2012-07-10 14:35:58 -04:00
Sam Soffes
fdb1726299 Merge pull request #27 from nivektric/0.2.2
Bump version number in podspec
2012-07-09 21:39:27 -07:00
Kevin Monahan
709006228c Bump version number in podspec 2012-07-09 23:47:10 -04:00
Sam Soffes
db0c62c481 Bump license year and add podspec 2012-06-02 13:32:57 -07:00
Sam Soffes
d9ea638369 Merge pull request #23 from jparishy/master
Fix for issues with Unicode filenames and Symbolic Links. Fixes #14
2012-05-09 21:32:13 -07:00
Julius Parishy
f18a98e551 Remote old debug NSLogs
Just taking out some NSLogs I missed when cleaning up the source.
2012-05-09 23:55:36 -04:00
Julius Parishy
557e869222 Remove files I accidentally unzipped.
They weren't needed and were cluttering up the directory.
2012-05-09 23:54:47 -04:00
Julius Parishy
26630b36af Fix for mailing tests regarding unicode filenames and symbolic links.
See my note about ZIPs lack of documentation for symbolic links. A lot
of this seems to be trial and error on my part as the implementation
isn't documented. This seems to do the trick, however, and all of the
tests are now passing on my end.

As always, send more problems my way.
2012-05-09 23:53:22 -04:00
Sam Soffes
581adbb98c Don't clean output director for debugging purposes 2012-05-09 09:54:16 -07:00
Sam Soffes
d646bf93a2 Add failing test for #14 2012-05-09 09:53:06 -07:00
Sam Soffes
b7598bc95f Version 0.2.1 2012-05-09 09:53:06 -07:00
Sam Soffes
236fcb7d65 Merge pull request #20 from florianbachmann/master
get rid of these three little warnings
2012-05-09 08:39:01 -07:00
Sam Soffes
a46e35e2b8 Remove warning in tests
* Switch to SSToolkit MD5 implementation
* Fix warning in MD5 implementation
2012-05-09 08:38:19 -07:00
Florian Bachmann
e171229257 get rid of these three warnings:
- Missing field 'tm_min' initializer
- Suggest braces around initialization of subobject
- Missing field 'dosDate' initializer
2012-05-09 08:38:19 -07:00
Sam Soffes
3a87f3ccfa Merge pull request #21 from EgoAleSum/patch-1
Fixed two warnings
2012-05-09 08:32:10 -07:00
Sam Soffes
df4ffca706 Merge pull request #22 from jparishy/preserve-symbolic-links
Preserve symbolic links. Fixes #5
2012-05-09 08:31:40 -07:00
Julius Parishy
64c542e090 Clean up and fix bug in test.
I commented out a bunch of NSLogs while debugging so I put those back
in, and fixed a bug where the test would crash if the symbolic link
failed to be created.
2012-05-09 11:14:56 -04:00
Julius Parishy
f900d38036 Symbolic Link support.
Adds support for ZIP files that include files that are symbolic links.
See the note in SSZipArchive.m for more information about that.
Includes a test that will probably only pass if you have GitHub for Mac
installed because that's the program I used as a test to symlink
against.

I created the symbolic link with 'ln -s /Applications/GitHub.app
SymbolicLink/GitHub.app' so I'm not entirely sure how it'll behave for
hard links, but I can't test that right now.
2012-05-09 11:12:04 -04:00
Alessandro Segala
9070c825f8 Fixed two warnings 2012-05-09 16:35:09 +02:00
Julius Parishy
bfc0904d14 Looking into the symbolic link issue.
http://www.pkware.com/documents/casestudies/APPNOTE.TXT
2012-05-09 08:18:19 -04:00
Florian Bachmann
45009d71e7 get rid of these three warnings:
- Missing field 'tm_min' initializer
- Suggest braces around initialization of subobject
- Missing field 'dosDate' initializer
2012-05-09 11:17:44 +02:00
Sam Soffes
b27c74b04c Merge pull request #19 from jparishy/master
Fix for Issue #16. Closes #16
2012-05-08 20:35:18 -07:00
Julius Parishy
b6f7f605fe Fix for Issue #16
Fixes issues with files being truncated when their headers have values
that represent smaller uncompressed sizes then the actual data. This
generally fixes issues where the whatever program zipped the file
fucked up the headers. The fix makes ssziparchive behave like other
unzip utilities that ignore the header and decompress the actual data
until it's finished.

I've tested a bunch and all of the tests included pass, if any other
issues arrive I'd be glad to take additional time to look into it.

Includes a file, IncorrectHeaders.zip, that is a zip of a folder called
IncorrectHeaders which includes a single file, Readme.txt. I've
intentionally changed the header for that file to read 50 bytes intend
of the actual 59 for testing purposes.
2012-05-08 22:55:30 -04:00
Sam Soffes
f6eb58cc51 Verify delegate file indexes. Closes #18
Using `zip` in Terminal generates zip files with just the files you zip. If you use OS X's archiver, it will add hidden files making the indexes appear to be wrong.
2012-05-08 09:47:56 -07:00
Sam Soffes
5651fb2c1b Add ARC note to readme 2012-05-08 00:08:44 -07:00
15 changed files with 220 additions and 41 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@
*.perspectivev3
*.xcworkspace
xcuserdata
DerivedData

View File

@@ -1,12 +1,20 @@
# SSZipArchive Changelog
### Version 0.2.1
[Released May 9, 2012](https://github.com/samsoffes/sskeychain/tree/0.2.1)
* Support for symbolic links — [@jparishy](http://github.com/jparishy)
* Fix several warnings
### Version 0.2.0
[Released May 7, 2012](https://github.com/samsoffes/sskeychain/tree/0.2.0)
* Add unzipping delegate
* Add unzipping delegate — [@uppfinnarn](http://github.com/uppfinnarn)
* Fix unzipping with passwords
* Fix modified at dates
* Fix modified at dates — [@brantsears](http://github.com/brantsears)
* Fix truncated files. Ignore the zip headers and unzip until there is no more file. — [@jparishy](http://github.com/jparishy)
### Version 0.1.2

View File

@@ -1,4 +1,4 @@
Copyright (c) 2010-2011 Sam Soffes
Copyright (c) 2010-2013 Sam Soffes
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

View File

@@ -8,12 +8,15 @@ SSZipArchive is a simple utility class for zipping and unzipping files. Features
* Appending to zip files
* Zipping files
* Zipping NSData with a filename
* Works in ARC and non-ARC projects
## Adding to your project
1. Add `SSZipArchive.h`, `SSZipArchive.m`, and `minizip` to your project.
2. Add the `libz` library to your target
You don't need to do anything regarding ARC. SSZipArchive will detect if you're not using ARC and add the required memory management code.
## Usage
``` objective-c

View File

@@ -3,7 +3,7 @@
// SSZipArchive
//
// Created by Sam Soffes on 7/21/10.
// Copyright (c) Sam Soffes 2010-2011. All rights reserved.
// Copyright (c) Sam Soffes 2010-2013. All rights reserved.
//
#import <Foundation/Foundation.h>

View File

@@ -3,7 +3,7 @@
// SSZipArchive
//
// Created by Sam Soffes on 7/21/10.
// Copyright (c) Sam Soffes 2010-2011. All rights reserved.
// Copyright (c) Sam Soffes 2010-2013. All rights reserved.
//
#import "SSZipArchive.h"
@@ -11,6 +11,8 @@
#import "zlib.h"
#import "zconf.h"
#include <sys/stat.h>
#define CHUNK 16384
@interface SSZipArchive ()
@@ -105,11 +107,37 @@
[delegate zipArchiveWillUnzipFileAtIndex:currentFileNumber totalFiles:(NSInteger)globalInfo.number_entry
archivePath:path fileInfo:fileInfo];
}
char *filename = (char *)malloc(fileInfo.size_filename + 1);
unzGetCurrentFileInfo(zip, &fileInfo, filename, fileInfo.size_filename + 1, NULL, 0, NULL, 0);
filename[fileInfo.size_filename] = '\0';
//
// NOTE
// I used the ZIP spec from here:
// http://www.pkware.com/documents/casestudies/APPNOTE.TXT
//
// ...to deduce this method of detecting whether the file in the ZIP is a symbolic link.
// If it is, it is listed as a directory but has a data size greater than zero (real
// directories have it equal to 0) and the included, uncompressed data is the symbolic link path.
//
// ZIP files did not originally include support for symbolic links so the specification
// doesn't include anything in them that isn't part of a unix extension that isn't being used
// by the archivers we're testing. Most of this is figured out through trial and error and
// reading ZIP headers in hex editors. This seems to do the trick though.
//
const uLong ZipCompressionMethodStore = 0;
BOOL fileIsSymbolicLink = NO;
if((fileInfo.compression_method == ZipCompressionMethodStore) && // Is it compressed?
(S_ISDIR(fileInfo.external_fa)) && // Is it marked as a directory
(fileInfo.compressed_size > 0)) // Is there any data?
{
fileIsSymbolicLink = YES;
}
// Check if it contains directory
NSString *strPath = [NSString stringWithCString:filename encoding:NSUTF8StringEncoding];
BOOL isDirectory = NO;
@@ -137,41 +165,72 @@
NSLog(@"[SSZipArchive] Error: %@", err.localizedDescription);
}
[directoriesModificationDates addObject: [NSDictionary dictionaryWithObjectsAndKeys:fullPath, @"path", modDate, @"modDate", nil]];
if(!fileIsSymbolicLink)
[directoriesModificationDates addObject: [NSDictionary dictionaryWithObjectsAndKeys:fullPath, @"path", modDate, @"modDate", nil]];
if ([fileManager fileExistsAtPath:fullPath] && !isDirectory && !overwrite) {
unzCloseCurrentFile(zip);
ret = unzGoToNextFile(zip);
continue;
}
FILE *fp = fopen((const char*)[fullPath UTF8String], "wb");
while (fp) {
int readBytes = unzReadCurrentFile(zip, buffer, 4096);
if(!fileIsSymbolicLink)
{
FILE *fp = fopen((const char*)[fullPath UTF8String], "wb");
while (fp) {
int readBytes = unzReadCurrentFile(zip, buffer, 4096);
if (readBytes > 0) {
fwrite(buffer, readBytes, 1, fp );
} else {
break;
}
}
if (fp) {
fclose(fp);
// Set the original datetime property
if (fileInfo.dosDate != 0) {
NSDate *orgDate = [[self class] _dateWithMSDOSFormat:(UInt32)fileInfo.dosDate];
NSDictionary *attr = [NSDictionary dictionaryWithObject:orgDate forKey:NSFileModificationDate];
if (attr) {
if ([fileManager setAttributes:attr ofItemAtPath:fullPath error:nil] == NO) {
// Can't set attributes
NSLog(@"[SSZipArchive] Failed to set attributes");
}
}
}
}
if (readBytes > 0) {
fwrite(buffer, readBytes, 1, fp );
} else {
break;
}
}
if (fp) {
fclose(fp);
// Set the original datetime property
if (fileInfo.dosDate != 0) {
NSDate *orgDate = [[self class] _dateWithMSDOSFormat:(UInt32)fileInfo.dosDate];
NSDictionary *attr = [NSDictionary dictionaryWithObject:orgDate forKey:NSFileModificationDate];
if (attr) {
if ([fileManager setAttributes:attr ofItemAtPath:fullPath error:nil] == NO) {
// Can't set attributes
NSLog(@"[SSZipArchive] Failed to set attributes");
}
}
}
}
}
else
{
// Get the path for the symbolic link
NSURL* symlinkURL = [NSURL fileURLWithPath:fullPath];
NSMutableString* destinationPath = [NSMutableString string];
int bytesRead = 0;
while((bytesRead = unzReadCurrentFile(zip, buffer, 4096)) > 0)
{
buffer[bytesRead] = 0;
[destinationPath appendString:[NSString stringWithUTF8String:(const char*)buffer]];
}
//NSLog(@"Symlinking to: %@", destinationPath);
NSURL* destinationURL = [NSURL fileURLWithPath:destinationPath];
// Create the symbolic link
NSError* symlinkError = nil;
[fileManager createSymbolicLinkAtURL:symlinkURL withDestinationURL:destinationURL error:&symlinkError];
if(symlinkError != nil)
{
NSLog(@"Failed to create symbolic link at \"%@\" to \"%@\". Error: %@", symlinkURL.absoluteString, destinationURL.absoluteString, symlinkError.localizedDescription);
}
}
unzCloseCurrentFile( zip );
ret = unzGoToNextFile( zip );
@@ -290,6 +349,7 @@
zipCloseFileInZip(_zip);
free(buffer);
fclose(input);
return YES;
}
@@ -301,7 +361,7 @@
if (!data) {
return NO;
}
zip_fileinfo zipInfo = {0};
zip_fileinfo zipInfo = {{0,0,0,0,0,0},0,0,0};
[self zipInfo:&zipInfo setDate:[NSDate date]];
zipOpenNewFileInZip(_zip, [filename UTF8String], &zipInfo, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION);

15
SSZipArchive.podspec Normal file
View File

@@ -0,0 +1,15 @@
Pod::Spec.new do |s|
s.name = 'SSZipArchive'
s.version = '0.2.3'
s.summary = 'Utility class for zipping and unzipping files on iOS and Mac.'
s.description = 'SSZipArchive is a simple utility class for zipping and unzipping files on iOS and Mac.'
s.homepage = 'https://github.com/soffes/ssziparchive'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Sam Soffes' => 'sam@soff.es' }
s.source = { :git => 'https://github.com/soffes/ssziparchive.git', :tag => '0.2.3' }
s.ios.deployment_target = '4.0'
s.osx.deployment_target = '10.6'
s.source_files = 'SSZipArchive.{h,m}', 'minizip/*.{h,c}'
s.preserve_paths = 'minizip'
s.library = 'z'
end

BIN
Tests/IncorrectHeaders.zip Normal file

Binary file not shown.

View File

@@ -17,7 +17,10 @@
B215FB6A143AD576003AC546 /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = B215FB53143AD460003AC546 /* unzip.c */; };
B215FB6B143AD576003AC546 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = B215FB55143AD460003AC546 /* zip.c */; };
B215FB6D143AD6FF003AC546 /* TestArchive.zip in Resources */ = {isa = PBXBuildFile; fileRef = B215FB6C143AD6FF003AC546 /* TestArchive.zip */; };
B2283D5D155AD80F00F9395A /* Unicode.zip in Resources */ = {isa = PBXBuildFile; fileRef = B2283D5C155AD80F00F9395A /* Unicode.zip */; };
B23FCC7F1558F1B70026375C /* TestPasswordArchive.zip in Resources */ = {isa = PBXBuildFile; fileRef = B23FCC7E1558F1B70026375C /* TestPasswordArchive.zip */; };
C5AE4E64155A12760045F3ED /* IncorrectHeaders.zip in Resources */ = {isa = PBXBuildFile; fileRef = C5AE4E63155A12760045F3ED /* IncorrectHeaders.zip */; };
C5AE4E6D155A8B010045F3ED /* SymbolicLink.zip in Resources */ = {isa = PBXBuildFile; fileRef = C5AE4E6C155A8B010045F3ED /* SymbolicLink.zip */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -39,7 +42,10 @@
B215FB61143AD514003AC546 /* SSZipArchiveTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSZipArchiveTests.m; sourceTree = "<group>"; };
B215FB64143AD527003AC546 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
B215FB6C143AD6FF003AC546 /* TestArchive.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = TestArchive.zip; sourceTree = "<group>"; };
B2283D5C155AD80F00F9395A /* Unicode.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = Unicode.zip; sourceTree = "<group>"; };
B23FCC7E1558F1B70026375C /* TestPasswordArchive.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = TestPasswordArchive.zip; sourceTree = "<group>"; };
C5AE4E63155A12760045F3ED /* IncorrectHeaders.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = IncorrectHeaders.zip; sourceTree = "<group>"; };
C5AE4E6C155A8B010045F3ED /* SymbolicLink.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = SymbolicLink.zip; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -114,10 +120,13 @@
B215FB5E143AD505003AC546 /* SSZipArchiveTests */ = {
isa = PBXGroup;
children = (
B2283D5C155AD80F00F9395A /* Unicode.zip */,
B215FB61143AD514003AC546 /* SSZipArchiveTests.m */,
B215FB5F143AD514003AC546 /* SSZipArchiveTests-Info.plist */,
C5AE4E63155A12760045F3ED /* IncorrectHeaders.zip */,
B215FB6C143AD6FF003AC546 /* TestArchive.zip */,
B23FCC7E1558F1B70026375C /* TestPasswordArchive.zip */,
C5AE4E6C155A8B010045F3ED /* SymbolicLink.zip */,
);
name = SSZipArchiveTests;
sourceTree = "<group>";
@@ -176,6 +185,9 @@
files = (
B215FB6D143AD6FF003AC546 /* TestArchive.zip in Resources */,
B23FCC7F1558F1B70026375C /* TestPasswordArchive.zip in Resources */,
C5AE4E64155A12760045F3ED /* IncorrectHeaders.zip in Resources */,
C5AE4E6D155A8B010045F3ED /* SymbolicLink.zip in Resources */,
B2283D5D155AD80F00F9395A /* Unicode.zip in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -8,18 +8,21 @@
#import "SSZipArchive.h"
#import <SenTestingKit/SenTestingKit.h>
#import <CommonCrypto/CommonDigest.h>
@interface SSZipArchiveTests : SenTestCase <SSZipArchiveDelegate>
- (NSString *)_cachesPath:(NSString *)directory;
- (NSString *)_calculateMD5Digest:(NSData *)data;
@end
@implementation SSZipArchiveTests
- (void)setUp {
[[NSFileManager defaultManager] removeItemAtPath:[self _cachesPath:nil] error:nil];
}
//- (void)setUp {
// [[NSFileManager defaultManager] removeItemAtPath:[self _cachesPath:nil] error:nil];
//}
- (void)testZipping {
@@ -66,6 +69,57 @@
STAssertTrue([fileManager fileExistsAtPath:testPath], @"LICENSE unzipped");
}
- (void)testUnzippingTruncatedFileFix {
NSString* zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"IncorrectHeaders" ofType:@"zip"];
NSString* outputPath = [self _cachesPath:@"IncorrectHeaders"];
[SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:self];
NSString* intendedReadmeTxtMD5 = @"31ac96301302eb388070c827447290b5";
NSString* filePath = [outputPath stringByAppendingPathComponent:@"IncorrectHeaders/Readme.txt"];
NSData* data = [NSData dataWithContentsOfFile:filePath];
NSString* actualReadmeTxtMD5 = [self _calculateMD5Digest:data];
STAssertTrue([actualReadmeTxtMD5 isEqualToString:intendedReadmeTxtMD5], @"Readme.txt MD5 digest should match original.");
}
- (void)testUnzippingWithSymlinkedFileInside {
NSString* zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"SymbolicLink" ofType:@"zip"];
NSString* outputPath = [self _cachesPath:@"SymbolicLink"];
[SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:self];
NSString *testSymlinkFolder = [outputPath stringByAppendingPathComponent:@"SymbolicLink/GitHub.app"];
NSString *testSymlinkFile = [outputPath stringByAppendingPathComponent:@"SymbolicLink/Icon.icns"];
NSError *error = nil;
NSString *symlinkFolderPath = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath:testSymlinkFolder error:&error];
bool symbolicLinkToFolderPersists = ((symlinkFolderPath != nil) && [symlinkFolderPath isEqualToString:@"/Applications/GitHub.app"]) && (error == nil);
error = nil;
NSString *symlinkFilePath = [[NSFileManager defaultManager] destinationOfSymbolicLinkAtPath:testSymlinkFile error:&error];
bool symbolicLinkToFilePersists = ((symlinkFilePath != nil) && [symlinkFilePath isEqualToString:@"/Applications/GitHub.app/Contents/Resources/AppIcon.icns"]) && (error == nil);
STAssertTrue(symbolicLinkToFilePersists && symbolicLinkToFolderPersists, @"Symbolic links should persist from the original archive to the outputted files.");
}
- (void)testUnzippingWithUnicodeFilenameInside {
NSString* zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"Unicode" ofType:@"zip"];
NSString* outputPath = [self _cachesPath:@"Unicode"];
[SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:self];
bool unicodeFilenameWasExtracted = [[NSFileManager defaultManager] fileExistsAtPath:[outputPath stringByAppendingPathComponent:@"Accént.txt"]];
bool unicodeFolderWasExtracted = [[NSFileManager defaultManager] fileExistsAtPath:[outputPath stringByAppendingPathComponent:@"Fólder/Nothing.txt"]];
STAssertTrue(unicodeFilenameWasExtracted, @"Files with filenames in unicode should be extracted properly.");
STAssertTrue(unicodeFolderWasExtracted, @"Folders with names in unicode should be extracted propertly.");
}
// Commented out to avoid checking in several gig file into the repository. Simply add a file named
// `LargeArchive.zip` to the project and uncomment out these lines to test.
@@ -117,4 +171,16 @@
return path;
}
// Taken from https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/NSData+SSToolkitAdditions.m
- (NSString *)_calculateMD5Digest:(NSData *)data {
unsigned char digest[CC_MD5_DIGEST_LENGTH], i;
CC_MD5(data.bytes, (unsigned int)data.length, digest);
NSMutableString *ms = [NSMutableString string];
for (i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
[ms appendFormat: @"%02x", (int)(digest[i])];
}
return [ms copy];
}
@end

BIN
Tests/SymbolicLink.zip Normal file

Binary file not shown.

Binary file not shown.

BIN
Tests/Unicode.zip Normal file

Binary file not shown.

View File

@@ -1629,7 +1629,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
if (password != NULL)
{
int i;
s->pcrc_32_tab = get_crc_table();
s->pcrc_32_tab = (const unsigned long*)get_crc_table();
init_keys(password,s->keys,s->pcrc_32_tab);
if (ZSEEK64(s->z_filefunc, s->filestream,
s->pfile_in_zip_read->pos_in_zipfile +
@@ -1718,10 +1718,24 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
pfile_in_zip_read_info->stream.avail_out = (uInt)len;
// NOTE:
// This bit of code seems to try to set the amount of space in the output buffer based on the
// value stored in the headers stored in the .zip file. However, if those values are incorrect
// it may result in a loss of data when uncompresssing that file. The compressed data is still
// legit and will deflate without knowing the uncompressed code so this tidbit is unnecessary and
// may cause issues for some .zip files.
//
// It's removed in here to fix those issues.
//
// See: https://github.com/samsoffes/ssziparchive/issues/16
//
/*
if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
(!(pfile_in_zip_read_info->raw)))
pfile_in_zip_read_info->stream.avail_out =
(uInt)pfile_in_zip_read_info->rest_read_uncompressed;
*/
if ((len>pfile_in_zip_read_info->rest_read_compressed+
pfile_in_zip_read_info->stream.avail_in) &&

View File

@@ -1250,7 +1250,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
unsigned char bufHead[RAND_HEAD_LEN];
unsigned int sizeHead;
zi->ci.encrypt = 1;
zi->ci.pcrc_32_tab = get_crc_table();
zi->ci.pcrc_32_tab = (const unsigned long*)get_crc_table();
/*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/
sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting);