Re: convert password from SecKeychainFindGenericPassword to NSString

2010-02-01 Thread Jens Alfke
On Feb 1, 2010, at 3:58 AM, Stuart Malin wrote: > My code worked fine with NSString's +stringWithCString:length: even though > the string was not NULL terminated. Ah, you're right, I'd forgotten that method. It doesn't look for a NUL terminator because the length is given explicitly. You st

Re: convert password from SecKeychainFindGenericPassword to NSString

2010-02-01 Thread Stuart Malin
On Jan 31, 2010, at 9:49 PM, Kyle Sluder wrote: > On Sun, Jan 31, 2010 at 6:28 PM, Stuart Malin wrote: >> If I use +dataWithBytes:length: then I need to specify a length 1 greater, >> and that additional byte must be set to 0 (to null terminate the string). >> So, I could use NSMutableData, th

Re: convert password from SecKeychainFindGenericPassword to NSString

2010-02-01 Thread Stuart Malin
On Jan 31, 2010, at 9:53 PM, Jens Alfke wrote: > No. You don't want to pass a null terminated string to anything but the > methods that explicitly take a C string. Anything else just wants the > characters, with no nulls. > > --Jens {via iPhone} NSString's +stringWithCString:encoding: does

Re: convert password from SecKeychainFindGenericPassword to NSString

2010-01-31 Thread Jens Alfke
No. You don't want to pass a null terminated string to anything but the methods that explicitly take a C string. Anything else just wants the characters, with no nulls. --Jens {via iPhone} On Jan 31, 2010, at 6:28 PM, Stuart Malin wrote: On Jan 31, 2010, at 9:12 PM, Kyle Sluder wrote:

Re: convert password from SecKeychainFindGenericPassword to NSString

2010-01-31 Thread Kyle Sluder
On Sun, Jan 31, 2010 at 6:28 PM, Stuart Malin wrote: > If I use +dataWithBytes:length: then I need to specify a length 1 greater, > and that additional byte must be set to 0 (to null terminate the string). So, > I could use NSMutableData, then -resetBytesInRange: to zero out the last > byte, wh

Re: convert password from SecKeychainFindGenericPassword to NSString

2010-01-31 Thread Stuart Malin
On Jan 31, 2010, at 9:12 PM, Kyle Sluder wrote: > On Sun, Jan 31, 2010 at 5:51 PM, Stuart Malin wrote: >> I acquire a password from a keychain using SecKeychainFindGenericPassword. >> That provides a non null terminated c string and a length. I had been using >> [NSString stringWithCString: le

Re: convert password from SecKeychainFindGenericPassword to NSString

2010-01-31 Thread Stephen J. Butler
On Sun, Jan 31, 2010 at 7:51 PM, Stuart Malin wrote: > I acquire a password from a keychain using SecKeychainFindGenericPassword. > That provides a non null terminated c string and a length. I had been using > [NSString stringWithCString: length:] to get an NSString instance of the > password.

Re: convert password from SecKeychainFindGenericPassword to NSString

2010-01-31 Thread Kyle Sluder
On Sun, Jan 31, 2010 at 5:51 PM, Stuart Malin wrote: > I acquire a password from a keychain using SecKeychainFindGenericPassword. > That provides a non null terminated c string and a length. I had been using > [NSString stringWithCString: length:] to get an NSString instance of the > password.