From 2a248f6b55bd269c86aaa147b9718b5439c1c16e Mon Sep 17 00:00:00 2001 From: Ibrahim Sha'ath Date: Tue, 1 Aug 2017 16:07:22 -0700 Subject: [PATCH 1/2] Add missing nullability specifier --- SSZipArchive/SSZipArchive.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SSZipArchive/SSZipArchive.m b/SSZipArchive/SSZipArchive.m index 918846d..57576c9 100755 --- a/SSZipArchive/SSZipArchive.m +++ b/SSZipArchive/SSZipArchive.m @@ -184,7 +184,7 @@ NSString *const SSZipArchiveErrorDomain = @"SSZipArchiveErrorDomain"; toDestination:(NSString *)destination preserveAttributes:(BOOL)preserveAttributes overwrite:(BOOL)overwrite - password:(NSString *)password + password:(nullable NSString *)password error:(NSError **)error delegate:(id)delegate progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler From 6781d9734306129da571b11af2298e2f233ab046 Mon Sep 17 00:00:00 2001 From: Ibrahim Sha'ath Date: Tue, 1 Aug 2017 16:08:00 -0700 Subject: [PATCH 2/2] Guard against the receipt of empty paths --- SSZipArchive/SSZipArchive.h | 1 + SSZipArchive/SSZipArchive.m | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/SSZipArchive/SSZipArchive.h b/SSZipArchive/SSZipArchive.h index bcfbb74..3e82491 100755 --- a/SSZipArchive/SSZipArchive.h +++ b/SSZipArchive/SSZipArchive.h @@ -21,6 +21,7 @@ typedef NS_ENUM(NSInteger, SSZipArchiveErrorCode) { SSZipArchiveErrorCodeFileInfoNotLoadable = -3, SSZipArchiveErrorCodeFileContentNotReadable = -4, SSZipArchiveErrorCodeFailedToWriteFile = -5, + SSZipArchiveErrorCodeInvalidArguments = -6, }; @protocol SSZipArchiveDelegate; diff --git a/SSZipArchive/SSZipArchive.m b/SSZipArchive/SSZipArchive.m index 57576c9..1921b15 100755 --- a/SSZipArchive/SSZipArchive.m +++ b/SSZipArchive/SSZipArchive.m @@ -190,6 +190,22 @@ NSString *const SSZipArchiveErrorDomain = @"SSZipArchiveErrorDomain"; progressHandler:(void (^)(NSString *entry, unz_file_info zipInfo, long entryNumber, long total))progressHandler completionHandler:(void (^)(NSString *path, BOOL succeeded, NSError * __nullable error))completionHandler { + + // Guard against empty strings + if ([path length] == 0 || [destination length] == 0) + { + NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"received invalid argument(s)"}; + NSError *err = [NSError errorWithDomain:SSZipArchiveErrorDomain code:SSZipArchiveErrorCodeInvalidArguments userInfo:userInfo]; + if (error) + { + *error = err; + } + if (completionHandler) + { + completionHandler(nil, NO, err); + } + } + // Begin opening zipFile zip = unzOpen((const char*)[path fileSystemRepresentation]); if (zip == NULL)