aboutsummaryrefslogtreecommitdiffstats
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
parent76563cf13092e21da3efd853c0721f782bbc0b83 (diff)
downloadsequelpro-ee585cfa63ae19c0a2ad946ba3c618391dc20c52.tar.gz
sequelpro-ee585cfa63ae19c0a2ad946ba3c618391dc20c52.tar.bz2
sequelpro-ee585cfa63ae19c0a2ad946ba3c618391dc20c52.zip
- Fix a crasher for blank passwordsrelease-0.9.6
-rw-r--r--Source/KeyChain.m21
-rw-r--r--Source/TableDocument.m4
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]];