From d4149241263bf0c4151d386e0cdbeac7de7c0521 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 21 Oct 2017 22:04:45 +0200 Subject: [PATCH] iOS: Get the length from the generator This fixes reading over the buffer if it is not zero terminated. Fortunately, this was almost always the case by pure luck. --- iOS/ShowDetailsController.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/iOS/ShowDetailsController.m b/iOS/ShowDetailsController.m index 7f3642b..4d0e53a 100644 --- a/iOS/ShowDetailsController.m +++ b/iOS/ShowDetailsController.m @@ -200,10 +200,11 @@ clearNSMutableString(NSMutableString *string) free(passphrase); } - NSMutableString *password = [NSMutableString - stringWithUTF8String: (char *)generator.output]; - of_explicit_memset(generator.output, 0, - strlen((char *)generator.output)); + NSMutableString *password = [[[NSMutableString alloc] + initWithBytes: (char *)generator.output + length: generator.length + encoding: NSUTF8StringEncoding] autorelease]; + of_explicit_memset(generator.output, 0, generator.length); dispatch_sync(dispatch_get_main_queue(), ^ { activityController.view.hidden = YES;