Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash fixes #856

Merged
merged 2 commits into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Changes in Matrix iOS SDK in 0.16.6 (2020-05-xx)

Improvements:

Bug fix:
* MXSecretShareManager: Fix crash in cancelRequestWithRequestId (vector-im/riot-ios/issues/3272).
* MXIdentityService: Fix crash in handleHTTPClientError (vector-im/riot-ios/issues/3273).

Changes in Matrix iOS SDK in 0.16.5 (2020-05-18)
================================================

Expand Down
14 changes: 10 additions & 4 deletions MatrixSDK/Crypto/CrossSigning/MXCrossSigning.m
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,11 @@ - (void)requestPrivateKeysToDeviceIds:(nullable NSArray<NSString*>*)deviceIds
return isSecretValid;
} failure:^(NSError * _Nonnull error) {
// Cancel the other request
[self.crypto.secretShareManager cancelRequestWithRequestId:sskRequestId success:^{} failure:^(NSError * _Nonnull error) {
}];
if (sskRequestId)
{
[self.crypto.secretShareManager cancelRequestWithRequestId:sskRequestId success:^{} failure:^(NSError * _Nonnull error) {
}];
}
failure(error);
}];

Expand Down Expand Up @@ -340,8 +343,11 @@ - (void)requestPrivateKeysToDeviceIds:(nullable NSArray<NSString*>*)deviceIds
return isSecretValid;
} failure:^(NSError * _Nonnull error) {
// Cancel the other request
[self.crypto.secretShareManager cancelRequestWithRequestId:uskRequestId success:^{} failure:^(NSError * _Nonnull error) {
}];
if (uskRequestId)
{
[self.crypto.secretShareManager cancelRequestWithRequestId:uskRequestId success:^{} failure:^(NSError * _Nonnull error) {
}];
}
failure(error);
}];

Expand Down
13 changes: 11 additions & 2 deletions MatrixSDK/Crypto/KeySharing/Secret/MXSecretShareManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ - (MXHTTPOperation *)cancelRequestWithRequestId:(NSString*)requestId
{
NSLog(@"[MXSecretShareManager] cancelRequestWithRequestId: %@", requestId);

// Sanity check
if (!requestId)
{
NSLog(@"[MXSecretShareManager] cancelRequestWithRequestId: Nil request id");
failure(nil);
}

// Create an empty operation that will be mutated later
MXHTTPOperation *operation = [[MXHTTPOperation alloc] init];

Expand All @@ -118,8 +125,10 @@ - (MXHTTPOperation *)cancelRequestWithRequestId:(NSString*)requestId
MXPendingSecretShareRequest *pendingRequest = self->pendingSecretShareRequests[requestId];
if (!pendingRequest)
{
NSLog(@"[MXSecretShareManager] cancelRequestWithRequestId: Unknown request: %@", requestId);
failure(nil);
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"[MXSecretShareManager] cancelRequestWithRequestId: Unknown request: %@", requestId);
failure(nil);
});
}

[self->pendingSecretShareRequests removeObjectForKey:requestId];
Expand Down
1 change: 1 addition & 0 deletions MatrixSDK/IdentityServer/MXIdentityService.m
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ - (void)handleHTTPClientError:(NSNotification*)nofitication
NSString *accessToken = self.restClient.accessToken;

if (httpClient
&& self.identityServer
&& [httpClient.baseURL.absoluteString hasPrefix:self.identityServer]
&& [mxError.errcode isEqualToString:kMXErrCodeStringTermsNotSigned] && accessToken)
{
Expand Down