Browse Source

IOS-2888 fixes: truncated password send for SMTP if unicode chars are used in password (caused by messing with data wrongly and needlessly instead of using NSString directly)

IOS-2888
Andreas Buff 11 months ago
parent
commit
40ce49ba52
2 changed files with 11 additions and 39 deletions
  1. +10
    -38
      pantomime-lib/Framework/Pantomime/CWSMTP.m
  2. +1
    -1
      pantomime-lib/Framework/Pantomime/CWService.m

+ 10
- 38
pantomime-lib/Framework/Pantomime/CWSMTP.m View File

@ -570,46 +570,18 @@ static inline CWInternetAddress *next_recipient(NSMutableArray *theRecipients, B
//
- (void) _parseAUTH_PLAIN
{
NSData *aData;
aData = [_responsesFromServer lastObject];
if ([aData hasCPrefix: "334"])
{
NSMutableData *aMutableData;
NSUInteger len_username, len_password;
len_username = [_username length];
if (!_password)
{
len_password = 0;
}
else
{
len_password = [_password length];
}
// We create our phrase
aMutableData = [NSMutableData dataWithLength: (len_username + len_password + 2)];
[aMutableData replaceBytesInRange: NSMakeRange(1,len_username)
withBytes: [[_username dataUsingEncoding: _defaultCStringEncoding] bytes]];
[aMutableData replaceBytesInRange: NSMakeRange(2 + len_username, len_password)
withBytes: [[_password dataUsingEncoding: [NSString defaultCStringEncoding]] bytes]];
NSData *aData = [_responsesFromServer lastObject];
[self bulkWriteData:@[[aMutableData encodeBase64WithLineLength: 0],
_crlf]];
}
else if ([aData hasCPrefix: "235"])
{
AUTHENTICATION_COMPLETED(_delegate, @"PLAIN");
if ([aData hasCPrefix: "334"]) {
NSString *stringToSend = [NSString stringWithFormat:@"\0%@\0%@", _username, _password];
NSData *dataToSend = [stringToSend dataUsingEncoding:_defaultCStringEncoding];
[self bulkWriteData:@[[dataToSend encodeBase64WithLineLength: 0],
_crlf]];
} else if ([aData hasCPrefix: "235"]) {
AUTHENTICATION_COMPLETED(_delegate, @"PLAIN");
}
else
{
AUTHENTICATION_FAILED(_delegate, @"PLAIN");
else {
AUTHENTICATION_FAILED(_delegate, @"PLAIN");
}
}


+ 1
- 1
pantomime-lib/Framework/Pantomime/CWService.m View File

@ -67,7 +67,7 @@
self = [super init];
if (self) {
_crlf = [[NSData alloc] initWithBytes: "\r\n" length: 2];
_defaultCStringEncoding = [NSString defaultCStringEncoding];
_defaultCStringEncoding = NSUTF8StringEncoding; //[NSString defaultCStringEncoding]; //???
_supportedMechanisms = [[CWThreadSafeArray alloc] init];
_responsesFromServer = [[CWThreadSafeArray alloc] init];


Loading…
Cancel
Save