summaryrefslogtreecommitdiffstats
path: root/macosx/HBDistributedArray.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2016-12-27 11:53:11 +0100
committerDamiano Galassi <[email protected]>2016-12-27 11:53:11 +0100
commit2cc18941fa64a74d0f86f00215f112d940266585 (patch)
tree45b4d9b423ebcc5be8605e413af3fc021359e3f9 /macosx/HBDistributedArray.m
parentec1553108f3881a380904bcc8be7c19a626cb69a (diff)
MacGui: enable NSSecureCoding for the queue file.
Diffstat (limited to 'macosx/HBDistributedArray.m')
-rw-r--r--macosx/HBDistributedArray.m14
1 files changed, 12 insertions, 2 deletions
diff --git a/macosx/HBDistributedArray.m b/macosx/HBDistributedArray.m
index d5cb38976..432e5cd29 100644
--- a/macosx/HBDistributedArray.m
+++ b/macosx/HBDistributedArray.m
@@ -59,6 +59,8 @@ NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk";
@property (nonatomic, readonly) NSURL *fileURL;
@property (nonatomic, readwrite) NSTimeInterval modifiedTime;
+@property (nonatomic, readonly) NSSet *objectClasses;
+
@property (nonatomic, readonly) sem_t *mutex;
@property (nonatomic, readwrite) uint32_t mutexCount;
@@ -66,13 +68,14 @@ NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk";
@implementation HBDistributedArray
-- (instancetype)initWithURL:(NSURL *)fileURL
+- (instancetype)initWithURL:(NSURL *)fileURL class:(Class)objectClass
{
self = [super init];
if (self)
{
_fileURL = [fileURL copy];
_array = [[NSMutableArray alloc] init];
+ _objectClasses = [NSSet setWithObjects:[NSMutableArray class], objectClass, nil];
NSArray *runningInstances = [NSRunningApplication runningApplicationsWithBundleIdentifier:[[NSBundle mainBundle] bundleIdentifier]];
const char *name = [NSString stringWithFormat:@"/%@.hblock", _fileURL.lastPathComponent].UTF8String;
@@ -196,7 +199,14 @@ NSString *HBDistributedArraWrittenToDisk = @"HBDistributedArraWrittenToDisk";
NSMutableArray *jobsArray = nil;
@try
{
- jobsArray = [NSKeyedUnarchiver unarchiveObjectWithFile:self.fileURL.path];
+ NSData *queue = [NSData dataWithContentsOfURL:self.fileURL];
+ NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:queue];
+ if ([unarchiver respondsToSelector:@selector(requiresSecureCoding)])
+ {
+ unarchiver.requiresSecureCoding = YES;
+ }
+ jobsArray = [unarchiver decodeObjectOfClasses:self.objectClasses forKey:NSKeyedArchiveRootObjectKey];
+ [unarchiver finishDecoding];
}
@catch (NSException *exception)
{