From 1565db3feca0b97b57b8caefffc206f2dfdc9803 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 9 May 2021 22:51:50 -0700 Subject: [PATCH] Add secure coding to SPUUserUpdateState --- Sparkle/SPUUserUpdateState.m | 25 +++++++++++++++++++++++++ Sparkle/SUAppcastItem+Private.h | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Sparkle/SPUUserUpdateState.m b/Sparkle/SPUUserUpdateState.m index 6cef2526..935f6766 100644 --- a/Sparkle/SPUUserUpdateState.m +++ b/Sparkle/SPUUserUpdateState.m @@ -12,6 +12,10 @@ #include "AppKitPrevention.h" +#define SPUUserUpdateStateStageKey @"SPUUserUpdateStateStage" +#define SPUUserUpdateStateUserInitiatedKey @"SPUUserUpdateStateUserInitiated" +#define SPUUserUpdateStateMajorUpgradeKey @"SPUUserUpdateStateMajorUpgrade" + @implementation SPUUserUpdateState @synthesize stage = _stage; @@ -29,4 +33,25 @@ return self; } +- (void)encodeWithCoder:(NSCoder *)encoder +{ + [encoder encodeInteger:self.stage forKey:SPUUserUpdateStateStageKey]; + [encoder encodeBool:self.userInitiated forKey:SPUUserUpdateStateUserInitiatedKey]; + [encoder encodeBool:self.majorUpgrade forKey:SPUUserUpdateStateMajorUpgradeKey]; +} + +- (instancetype)initWithCoder:(NSCoder *)decoder +{ + SPUUserUpdateStage stage = [decoder decodeIntegerForKey:SPUUserUpdateStateStageKey]; + BOOL userInitiated = [decoder decodeBoolForKey:SPUUserUpdateStateUserInitiatedKey]; + BOOL majorUpgrade = [decoder decodeBoolForKey:SPUUserUpdateStateMajorUpgradeKey]; + + return [self initWithStage:stage userInitiated:userInitiated majorUpgrade:majorUpgrade]; +} + ++ (BOOL)supportsSecureCoding +{ + return YES; +} + @end diff --git a/Sparkle/SUAppcastItem+Private.h b/Sparkle/SUAppcastItem+Private.h index 77f7a017..b368c6a8 100644 --- a/Sparkle/SUAppcastItem+Private.h +++ b/Sparkle/SUAppcastItem+Private.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN -@interface SUAppcastItem (Private) +@interface SUAppcastItem (Private) // Initializes with data from a dictionary provided by the RSS class. - (nullable instancetype)initWithDictionary:(NSDictionary *)dict relativeToURL:(NSURL * _Nullable)appcastURL failureReason:(NSString * _Nullable __autoreleasing *_Nullable)error;