aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPKeychain.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-09-04 11:07:42 +0000
committerBibiko <bibiko@eva.mpg.de>2009-09-04 11:07:42 +0000
commit51246e91d7709ea1083039be88b9076bec7b3c44 (patch)
tree69f1616d6827e6903dd6ea3c020b2719340ca4af /Source/SPKeychain.m
parent630b3e761d18ed1aee962b73a288fe2dbafb5d48 (diff)
downloadsequelpro-51246e91d7709ea1083039be88b9076bec7b3c44.tar.gz
sequelpro-51246e91d7709ea1083039be88b9076bec7b3c44.tar.bz2
sequelpro-51246e91d7709ea1083039be88b9076bec7b3c44.zip
• the in r1313 introduced method [NSString stringWithCString:encoding:] must be a \0 terminated cString
- fixed that and replaced the deprecated method [NSString stringWithCString:length] again
Diffstat (limited to 'Source/SPKeychain.m')
-rw-r--r--Source/SPKeychain.m11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/SPKeychain.m b/Source/SPKeychain.m
index 4a62c310..e808d3ea 100644
--- a/Source/SPKeychain.m
+++ b/Source/SPKeychain.m
@@ -129,6 +129,7 @@
NULL, // default keychain
strlen([name UTF8String]), // length of service name (bytes)
[name UTF8String], // service name
+
strlen([account UTF8String]), // length of account name (bytes)
[account UTF8String], // account name
&passwordLength, // length of password
@@ -137,9 +138,13 @@
);
if (status == noErr) {
- password = [NSString stringWithCString:passwordData length:passwordLength];
- // password = [NSString stringWithCString:passwordData encoding:NSUTF8StringEncoding];
-
+ // Create a \0 terminated cString out of passwordData
+ char passwordBuf[passwordLength + 1];
+ strncpy(passwordBuf, passwordData, (size_t)passwordLength);
+ passwordBuf[passwordLength] = '\0';
+
+ password = [NSString stringWithCString:passwordBuf encoding:NSUTF8StringEncoding];
+
// Free the data allocated by SecKeychainFindGenericPassword:
SecKeychainItemFreeContent(
NULL, // No attribute data to release