aboutsummaryrefslogtreecommitdiffstats
path: root/Source/KeyChain.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-08-11 16:37:09 +0000
committerrowanbeentje <rowan@beent.je>2009-08-11 16:37:09 +0000
commitee585cfa63ae19c0a2ad946ba3c618391dc20c52 (patch)
tree86b64af27ff650fca70bf95ed666d6be4ba36364 /Source/KeyChain.m
parent76563cf13092e21da3efd853c0721f782bbc0b83 (diff)
downloadsequelpro-ee585cfa63ae19c0a2ad946ba3c618391dc20c52.tar.gz
sequelpro-ee585cfa63ae19c0a2ad946ba3c618391dc20c52.tar.bz2
sequelpro-ee585cfa63ae19c0a2ad946ba3c618391dc20c52.zip
- Fix a crasher for blank passwordsrelease-0.9.6
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;