From afc4179c0d151b306bf1644c8a2a349ec6b981df Mon Sep 17 00:00:00 2001 From: Daniel Jalkut Date: Mon, 28 Apr 2025 20:40:08 -0400 Subject: [PATCH] Rework the logic for avoiding re-sending the system profile more frequently than once a week (#2720) So that it will not use a potentially problematic binary compare operation. Fixes #278. --- Sparkle/SPUUpdater.m | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Sparkle/SPUUpdater.m b/Sparkle/SPUUpdater.m index c549734e..88cf580c 100644 --- a/Sparkle/SPUUpdater.m +++ b/Sparkle/SPUUpdater.m @@ -1094,12 +1094,17 @@ static NSString *escapeURLComponent(NSString *str) { BOOL sendingSystemProfile = [self sendsSystemProfile]; // Let's only send the system profiling information once per week at most, so we normalize daily-checkers vs. biweekly-checkers and the such. - NSDate *lastSubmitDate = [_host objectForUserDefaultsKey:SULastProfileSubmitDateKey]; - if (!lastSubmitDate) { - lastSubmitDate = [NSDate distantPast]; + if (sendingSystemProfile) { + NSDate *lastSubmitDate = [_host objectForUserDefaultsKey:SULastProfileSubmitDateKey]; + if (!lastSubmitDate) { + lastSubmitDate = [NSDate distantPast]; + } + const NSTimeInterval oneWeek = 60 * 60 * 24 * 7; + NSTimeInterval timeSinceLastSubmission = [lastSubmitDate timeIntervalSinceNow] * -1; + if (timeSinceLastSubmission < oneWeek) { + sendingSystemProfile = NO; + } } - const NSTimeInterval oneWeek = 60 * 60 * 24 * 7; - sendingSystemProfile &= (-[lastSubmitDate timeIntervalSinceNow] >= oneWeek); id delegate = _delegate; NSArray *> *parameters = @[];