Fixed bug where getting non existing passwords would throw on ARM processors. #1
This commit is contained in:
parent
30217ff1b5
commit
b27fc72c8d
|
@ -53,21 +53,23 @@ RCT_EXPORT_METHOD(getInternetCredentialsForServer:(NSString*)server callback:(RC
|
||||||
|
|
||||||
// Look up server in the keychain
|
// Look up server in the keychain
|
||||||
NSDictionary* found = nil;
|
NSDictionary* found = nil;
|
||||||
CFDictionaryRef foundCF;
|
CFTypeRef foundTypeRef = NULL;
|
||||||
OSStatus osStatus = SecItemCopyMatching((__bridge CFDictionaryRef) dict, (CFTypeRef*)&foundCF);
|
OSStatus osStatus = SecItemCopyMatching((__bridge CFDictionaryRef) dict, (CFTypeRef*)&foundTypeRef);
|
||||||
|
|
||||||
found = (__bridge NSDictionary*)(foundCF);
|
|
||||||
if (!found) return callback(@[[NSNull null]]);
|
|
||||||
|
|
||||||
// Found
|
|
||||||
NSString* username = (NSString*) [found objectForKey:(__bridge id)(kSecAttrAccount)];
|
|
||||||
NSString* password = [[NSString alloc] initWithData:[found objectForKey:(__bridge id)(kSecValueData)] encoding:NSUTF8StringEncoding];
|
|
||||||
|
|
||||||
if (osStatus != noErr) {
|
if (osStatus != noErr) {
|
||||||
NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:osStatus userInfo:nil];
|
NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:osStatus userInfo:nil];
|
||||||
return callback(@[makeError(error)]);
|
return callback(@[makeError(error)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
found = (__bridge NSDictionary*)(foundTypeRef);
|
||||||
|
if (!found) {
|
||||||
|
return callback(@[[NSNull null]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Found
|
||||||
|
NSString* username = (NSString*) [found objectForKey:(__bridge id)(kSecAttrAccount)];
|
||||||
|
NSString* password = [[NSString alloc] initWithData:[found objectForKey:(__bridge id)(kSecValueData)] encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
callback(@[[NSNull null], username, password]);
|
callback(@[[NSNull null], username, password]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue