From 4661fee38827ecb95fefc051deea4d61a689e1c2 Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 18 May 2016 20:08:01 -0400 Subject: [PATCH] Deal with byte order when sending installation progress --- Sparkle/Autoupdate/AppInstaller.m | 15 +++++++++------ Sparkle/SUInstallerDriver.m | 5 +++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sparkle/Autoupdate/AppInstaller.m b/Sparkle/Autoupdate/AppInstaller.m index 2f9e8cda..ec5526dc 100644 --- a/Sparkle/Autoupdate/AppInstaller.m +++ b/Sparkle/Autoupdate/AppInstaller.m @@ -275,12 +275,15 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7; - (void)unarchiverExtractedProgress:(double)progress { - NSData *data = [NSData dataWithBytes:&progress length:sizeof(progress)]; - [self.remotePort sendMessageWithIdentifier:SUExtractedArchiveWithProgress data:data completion:^(BOOL success) { - if (!success) { - SULog(@"Error sending extracted progress"); - } - }]; + if (sizeof(progress) == sizeof(uint64_t)) { + uint64_t progressValue = CFSwapInt64HostToLittle(*(uint64_t *)&progress); + NSData *data = [NSData dataWithBytes:&progressValue length:sizeof(progressValue)]; + [self.remotePort sendMessageWithIdentifier:SUExtractedArchiveWithProgress data:data completion:^(BOOL success) { + if (!success) { + SULog(@"Error sending extracted progress"); + } + }]; + } } - (void)unarchiverDidFail diff --git a/Sparkle/SUInstallerDriver.m b/Sparkle/SUInstallerDriver.m index f283f4f7..cc22885d 100644 --- a/Sparkle/SUInstallerDriver.m +++ b/Sparkle/SUInstallerDriver.m @@ -298,8 +298,9 @@ if (identifier == SURequestInstallationParameters) { [self sendInstallationData]; } else if (identifier == SUExtractedArchiveWithProgress) { - if (data.length == sizeof(double)) { - double progress = *(const double *)data.bytes; + if (data.length == sizeof(double) && sizeof(double) == sizeof(uint64_t)) { + uint64_t progressValue = CFSwapInt64LittleToHost(*(const uint64_t *)data.bytes); + double progress = *(double *)&progressValue; [self.delegate installerDidExtractUpdateWithProgress:progress]; self.currentStage = identifier; }