Deal with byte order when sending installation progress

This commit is contained in:
Zorg committed 2016-05-18 20:08:01 -04:00
1 parent 1a952227a7
commit 4661fee388
2 files changed
+12 -8

No files matched your search

+9 -6
View File
@@ -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
+3 -2
View File
@@ -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;
}