Skip to content

Commit

Permalink
avoid error dereference, fix string format warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-dt committed Apr 6, 2023
1 parent 008e41e commit a89123e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions TrustKit/Pinning/pinning_utils.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ void evaluateCertificateChainTrust(SecTrustRef serverTrust, SecTrustResultType *
CFErrorRef errorRef;
bool certificateEvaluationSucceeded = SecTrustEvaluateWithError(serverTrust, &errorRef);
OSStatus status = SecTrustGetTrustResult(serverTrust, trustResult);
if (status != errSecSuccess)
{
certificateEvaluationSucceeded = false;
NSString *errDescription = [NSString stringWithFormat:@"got status %d", status];
*error = [[NSError alloc] initWithDomain:@"com.datatheorem.trustkit" code:1 userInfo:@{NSLocalizedDescriptionKey:errDescription}];
}
else if (!certificateEvaluationSucceeded && (error != NULL))
{
*error = (__bridge_transfer NSError *)errorRef;
if (error != NULL) {
if (status != errSecSuccess)
{
certificateEvaluationSucceeded = false;
NSString *errDescription = [NSString stringWithFormat:@"got status %d", (int)status];
*error = [[NSError alloc] initWithDomain:@"com.datatheorem.trustkit" code:1 userInfo:@{NSLocalizedDescriptionKey:errDescription}];
}
else if (!certificateEvaluationSucceeded)
{
*error = (__bridge_transfer NSError *)errorRef;
}
}
}
else
Expand All @@ -37,7 +39,7 @@ void evaluateCertificateChainTrust(SecTrustRef serverTrust, SecTrustResultType *
OSStatus status = SecTrustEvaluate(serverTrust, trustResult);
#pragma clang diagnostic pop
if (status != errSecSuccess && (error != NULL)) {
NSString *errDescription = [NSString stringWithFormat:@"got status %d", status];
NSString *errDescription = [NSString stringWithFormat:@"got status %d", (int)status];
*error = [[NSError alloc] initWithDomain:@"com.datatheorem.trustkit" code:2 userInfo:@{NSLocalizedDescriptionKey:errDescription}];
}
}
Expand Down

0 comments on commit a89123e

Please sign in to comment.