-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Initially found with Sparkle 2.7.3 (SPM package).
When launching my app I was surprised by a crash with the following exception thrown:
Thread 1: "-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x600001209020"
To reproduce, in Terminal, run this:
defaults write <app_bundle_id> SULastCheckTime "this is a string masquerading as a date"
Then launch the app and see it crash when it auto-check for updates during launch.
In my case, this is most likely a direct manipulation of the user defaults that caused the entry to change from a date to a string. While this situation should not happen in normal usage, I think the app should also not crash because of this.
The problem comes from -[SPUUpdater lastUpdateCheckDate] which does not validate the type of object it gets. I can fix it by adding a check there and it does fix the crash.
I was on my way to make a pull request for this, but looking elsewhere in the same file I noticed the other values it gets from user defaults aren't validated either, meaning the problem likely isn't unique to SULastCheckTime. Shouldn't we more systematically check the types for the objects we get from user defaults?