From 251706d646e37d2e68104eec9dfece51963fd36a Mon Sep 17 00:00:00 2001 From: Andy Matuschak Date: Mon, 30 Jun 2008 23:21:51 -0700 Subject: [PATCH] Fixed a serious bug which could cause a server to DDoS'd in the case of appcast parse failure. Sparkle now sets the "last checked at" time when it makes the appcast request instead of on successful receipt of an appcast. --- SUBasicUpdateDriver.m | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/SUBasicUpdateDriver.m b/SUBasicUpdateDriver.m index 36c1477f..1bfbaad2 100644 --- a/SUBasicUpdateDriver.m +++ b/SUBasicUpdateDriver.m @@ -28,6 +28,7 @@ [appcast setDelegate:self]; [appcast setUserAgentString:[NSString stringWithFormat: @"%@/%@ Sparkle/1.5b2", [hostBundle name], [hostBundle displayVersion]]]; [appcast fetchAppcastFromURL:appcastURL]; + [[SUUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:SULastCheckTimeKey]; } - (BOOL)isItemNewer:(SUAppcastItem *)ui @@ -60,11 +61,7 @@ { if ([delegate respondsToSelector:@selector(appcastDidFinishLoading:forHostBundle:)]) [delegate appcastDidFinishLoading:ac forHostBundle:hostBundle]; - - NSArray* updates = [ac items]; - if ([updates count] > 0) - [[SUUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:SULastCheckTimeKey]; - + // Now we have to find the best valid update in the appcast. if ([delegate respondsToSelector:@selector(bestValidUpdateInAppcast:forHostBundle:)]) // Does the delegate want to handle it? { @@ -73,7 +70,7 @@ else // If not, we'll take care of it ourselves. { // Find the first update we can actually use. - NSEnumerator *updateEnumerator = [updates objectEnumerator]; + NSEnumerator *updateEnumerator = [[ac items] objectEnumerator]; do { updateItem = [updateEnumerator nextObject]; } while (updateItem && ![self hostSupportsItem:updateItem]);