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.
This commit is contained in:
Jonathan Schleifer 2017-10-21 22:04:45 +02:00
parent 8de675d32c
commit d414924126
No known key found for this signature in database
GPG key ID: 28D65178B37F33E3

View file

@ -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;