mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-19 13:43:22 +00:00
fix(crypto): check if NSData is null terminated
This commit is contained in:
@@ -660,7 +660,16 @@ static const NSString *kAES256GCMError = @"kAES256GCMError";
|
||||
|
||||
if (rv > 0) {
|
||||
if (outputData) {
|
||||
value = [NSString stringWithUTF8String: [outputData bytes]];
|
||||
char lastByte;
|
||||
[outputData getBytes:&lastByte range:NSMakeRange([outputData length]-1, 1)];
|
||||
if (lastByte == 0x0) {
|
||||
// string is null terminated
|
||||
value = [NSString stringWithUTF8String: [outputData bytes]];
|
||||
} else {
|
||||
// string is not null terminated
|
||||
value = [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding];
|
||||
[value autorelease];
|
||||
}
|
||||
} else {
|
||||
*ex = [NSException exceptionWithName: kAES256GCMError reason:@"Decryption ok but output empty" userInfo: nil];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user