diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index 3ef0c5ff..2a3c5b3e 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -150,7 +150,7 @@ NSBundle *bundle = host.bundle; assert(bundle != nil); - NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[bundle bundlePath] pathExtension]]]; + NSString *normalizedAppPath = [[[bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[bundle bundlePath] pathExtension]]]; return normalizedAppPath; } diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 586ce47f..26b27256 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -186,12 +186,15 @@ // Prevent malicious downgrades if (!allowDowngrades) { NSString *hostVersion = [self.host version]; + NSBundle *bundle = [NSBundle bundleWithPath:self.bundlePath]; - NSString *updateVersion = [bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]; + SUHost *updateHost = [[SUHost alloc] initWithBundle:bundle]; + NSString *updateVersion = [updateHost objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]; + id comparator = [[SUStandardVersionComparator alloc] init]; if (!updateVersion || [comparator compareVersion:hostVersion toVersion:updateVersion] == NSOrderedDescending) { if (error != NULL) { - NSString *errorMessage = [NSString stringWithFormat:@"For security reasons, updates that downgrade version of the application are not allowed. Refusing to downgrade app from version %@ to %@. Aborting update.", hostVersion, [bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]]; + NSString *errorMessage = [NSString stringWithFormat:@"For security reasons, updates that downgrade version of the application are not allowed. Refusing to downgrade app from version %@ to %@. Aborting update.", hostVersion, updateVersion]; *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; }