Guard against the receipt of empty paths

This commit is contained in:
Ibrahim Sha'ath
2017-08-01 16:08:00 -07:00
parent 2a248f6b55
commit 6781d97343
2 changed files with 17 additions and 0 deletions
+16
View File
@@ -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)