diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/KeyChain.m | 21 | ||||
-rw-r--r-- | Source/TableDocument.m | 4 |
2 files changed, 22 insertions, 3 deletions
diff --git a/Source/KeyChain.m b/Source/KeyChain.m index 483eeceb..26c56cbf 100644 --- a/Source/KeyChain.m +++ b/Source/KeyChain.m @@ -49,6 +49,11 @@ SecKeychainAttribute attributes[4]; SecKeychainAttributeList attList; + // Check supplied variables and replaces nils with empty strings + if (!name) name = @""; + if (!account) account = @""; + if (!label) label = @""; + // Check if password already exists before adding if (![self passwordExistsForName:name account:account]) { @@ -110,6 +115,10 @@ SecKeychainItemRef itemRef; NSString *password = @""; + // Check supplied variables and replaces nils with empty strings + if (!name) name = @""; + if (!account) account = @""; + status = SecKeychainFindGenericPassword( NULL, // default keychain strlen([name UTF8String]), // length of service name (bytes) @@ -142,6 +151,10 @@ OSStatus status; SecKeychainItemRef itemRef = nil; + // Check supplied variables and replaces nils with empty strings + if (!name) name = @""; + if (!account) account = @""; + // Check if password already exists before deleting if ([self passwordExistsForName:name account:account]) { status = SecKeychainFindGenericPassword( @@ -177,6 +190,10 @@ int numberOfItemsFound = 0; SecKeychainAttributeList list; SecKeychainAttribute attributes[2]; + + // Check supplied variables and replaces nils with empty strings + if (!name) name = @""; + if (!account) account = @""; attributes[0].tag = kSecAccountItemAttr; attributes[0].data = (void *)[account UTF8String]; // Account name @@ -209,7 +226,7 @@ NSString *keychainItemName; keychainItemName = [NSString stringWithFormat:@"Sequel Pro : %@ (%i)", - theName, + theName?theName:@"", [theID intValue]]; return keychainItemName; @@ -238,7 +255,7 @@ NSString *sshKeychainItemName; sshKeychainItemName = [NSString stringWithFormat:@"Sequel Pro SSHTunnel : %@ (%i)", - theName, + theName?theName:@"", [theID intValue]]; return sshKeychainItemName; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 526ddae0..d5c0d16f 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -2096,7 +2096,9 @@ * Invoked when the current connection needs a password from the Keychain. */ - (NSString *)keychainPasswordForConnection:(MCPConnection *)connection -{ +{ + if (![connectionController connectionKeychainItemName]) return @""; + KeyChain *keychain = [[KeyChain alloc] init]; NSString *password = [keychain getPasswordForName:[connectionController connectionKeychainItemName] account:[connectionController connectionKeychainItemAccount]]; |