Skip to content
Browse files

Fixes an issue with wrong buffer length

Fixes #61
  • Loading branch information...
1 parent b237f19 commit eace4f44e99f89eaeb72b02da6a33b95e984238f @eofster committed Nov 4, 2013
Showing with 8 additions and 8 deletions.
  1. +8 −8 Classes/AKKeychain.m
View
16 Classes/AKKeychain.m
@@ -39,9 +39,9 @@ + (NSString *)passwordForServiceName:(NSString *)serviceName accountName:(NSStri
OSStatus findStatus;
findStatus = SecKeychainFindGenericPassword(NULL, // Default keychain.
- [serviceName length],
+ [serviceName lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
[serviceName UTF8String],
- [accountName length],
+ [accountName lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
[accountName UTF8String],
&passwordLength,
&passwordData,
@@ -70,11 +70,11 @@ + (BOOL)addItemWithServiceName:(NSString *)serviceName
// Add item to keychain.
addStatus = SecKeychainAddGenericPassword(NULL, // NULL for default keychain.
- [serviceName length],
+ [serviceName lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
[serviceName UTF8String],
- [accountName length],
+ [accountName lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
[accountName UTF8String],
- [password length],
+ [password lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
[password UTF8String],
NULL); // Don't need keychain item reference.
@@ -84,9 +84,9 @@ + (BOOL)addItemWithServiceName:(NSString *)serviceName
} else if (addStatus == errSecDuplicateItem) {
// Get the pointer to the duplicate item.
findStatus = SecKeychainFindGenericPassword(NULL, // Default keychain.
- [serviceName length],
+ [serviceName lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
[serviceName UTF8String],
- [accountName length],
+ [accountName lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
[accountName UTF8String],
NULL,
NULL,
@@ -96,7 +96,7 @@ + (BOOL)addItemWithServiceName:(NSString *)serviceName
// Modify password in the duplicate item.
modifyStatus = SecKeychainItemModifyAttributesAndData(keychainItemRef,
NULL, // No changes in attributes.
- [password length],
+ [password lengthOfBytesUsingEncoding:NSUTF8StringEncoding],
[password UTF8String]);
if (modifyStatus == noErr) {

0 comments on commit eace4f4

Please sign in to comment.
Something went wrong with that request. Please try again.