aboutsummaryrefslogtreecommitdiffstats
path: root/Source/KeyChain.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/KeyChain.m')
-rw-r--r--Source/KeyChain.m21
1 files changed, 19 insertions, 2 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;