Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent e8eac9f30b
commit 4ad7ca79b7

@ -117,6 +117,7 @@ NSString *const kOWSPrimaryStorage_MayHaveLinkedDevices = @"kTSStorageManager_Ma
OWSDevice *device = [MTLJSONAdapter modelOfClass:[self class] fromJSONDictionary:deviceAttributes error:error]; OWSDevice *device = [MTLJSONAdapter modelOfClass:[self class] fromJSONDictionary:deviceAttributes error:error];
if (device.deviceId < OWSDevicePrimaryDeviceId) { if (device.deviceId < OWSDevicePrimaryDeviceId) {
OWSFailDebug(@"Invalid device id: %lu", (unsigned long)device.deviceId); OWSFailDebug(@"Invalid device id: %lu", (unsigned long)device.deviceId);
*error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecodeJson, @"Invalid device id.");
return nil; return nil;
} }
return device; return device;
@ -181,7 +182,7 @@ NSString *const kOWSPrimaryStorage_MayHaveLinkedDevices = @"kTSStorageManager_Ma
} }
*success = NO; *success = NO;
OWSLogError(@"unable to decode date from %@", value); OWSLogError(@"unable to decode date from %@", value);
*error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecodeJson, @"Unable to decode date from %@"); *error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecodeJson, @"Unable to decode date from JSON.");
return nil; return nil;
} }
reverseBlock:^id(id value, BOOL *success, NSError **error) { reverseBlock:^id(id value, BOOL *success, NSError **error) {
@ -194,7 +195,7 @@ NSString *const kOWSPrimaryStorage_MayHaveLinkedDevices = @"kTSStorageManager_Ma
} }
} }
OWSLogError(@"unable to encode date from %@", value); OWSLogError(@"unable to encode date from %@", value);
*error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToEncodeJson, @"Unable to encode date"); *error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToEncodeJson, @"Unable to encode date to JSON.");
*success = NO; *success = NO;
return nil; return nil;
}]; }];

@ -54,6 +54,10 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable NSData *)encrypt:(NSData *)dataToEncrypt - (nullable NSData *)encrypt:(NSData *)dataToEncrypt
{ {
@try { @try {
// Exceptions can be thrown in a number of places in encryptUnsafe, e.g.:
//
// * Curve25519's generateSharedSecretFromPublicKey.
// * [HKDFKit deriveKey].
return [self encryptUnsafe:dataToEncrypt]; return [self encryptUnsafe:dataToEncrypt];
} @catch (NSException *exception) { } @catch (NSException *exception) {
OWSFailDebug(@"exception: %@ of type: %@ with reason: %@, user info: %@.", OWSFailDebug(@"exception: %@ of type: %@ with reason: %@, user info: %@.",

@ -54,15 +54,15 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable TSAttachmentPointer *)attachmentPointerFromProto:(SSKProtoAttachmentPointer *)attachmentProto + (nullable TSAttachmentPointer *)attachmentPointerFromProto:(SSKProtoAttachmentPointer *)attachmentProto
{ {
if (attachmentProto.id < 1) { if (attachmentProto.id < 1) {
OWSFailDebug("Invalid attachment id."); OWSFailDebug(@"Invalid attachment id.");
return nil; return nil;
} }
if (attachmentProto.key.length < 1) { if (attachmentProto.key.length < 1) {
OWSFailDebug("Invalid attachment key."); OWSFailDebug(@"Invalid attachment key.");
return nil; return nil;
} }
if (attachmentProto.contentType.length < 1) { if (attachmentProto.contentType.length < 1) {
OWSFailDebug("Invalid attachment content type."); OWSFailDebug(@"Invalid attachment content type.");
return nil; return nil;
} }

@ -1174,7 +1174,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
case SSKProtoGroupContextTypeQuit: { case SSKProtoGroupContextTypeQuit: {
if (!oldGroupThread) { if (!oldGroupThread) {
OWSFailDebug(@"ignoring quit group message from unknown group."); OWSLogWarn(@"ignoring quit group message from unknown group.");
return nil; return nil;
} }
[newMemberIds removeObject:envelope.source]; [newMemberIds removeObject:envelope.source];

@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
for (NSData *data in datas) { for (NSData *data in datas) {
[result appendData:data]; [result appendData:data];
} }
return result; return [result copy];
} }
- (NSData *)dataByAppendingData:(NSData *)data - (NSData *)dataByAppendingData:(NSData *)data

Loading…
Cancel
Save