X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fmodules%2Fsmtp%2Fserv_smtp.c;fp=citadel%2Fmodules%2Fsmtp%2Fserv_smtp.c;h=760ea5a82d2b7d2e03d16710a0ce7f5793ea03cc;hp=ece85545f85613712c737b483150304acca240db;hb=f267427a9cd245b476406f82823502f4279f450b;hpb=3a78b645b93edfaf7b8f31b3156372c3308f5531 diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index ece85545f..760ea5a82 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -444,24 +444,37 @@ void smtp_try_plain(long offset, long Flags) char user[256] = ""; char pass[256] = ""; int result; + + long decoded_len; long len; - len = StrBufDecodeBase64(sSMTP->Cmd); - if (len > 0) + memset(pass, 0, sizeof(pass)); + decoded_len = StrBufDecodeBase64(sSMTP->Cmd); + + if (decoded_len > 0) { decoded_authstring = ChrPtr(sSMTP->Cmd); len = safestrncpy(ident, decoded_authstring, sizeof ident); + decoded_len -= len - 1; decoded_authstring += len + 1; - len = safestrncpy(user, decoded_authstring, sizeof user); + if (decoded_len > 0) + { + len = safestrncpy(user, decoded_authstring, sizeof user); - decoded_authstring += len + 1; + decoded_authstring += len + 1; + decoded_len -= len - 1; + } + + if (decoded_len > 0) + { + len = safestrncpy(pass, decoded_authstring, sizeof pass); - len = safestrncpy(pass, decoded_authstring, sizeof pass); - if (len < 0) - len = sizeof(pass) - 1; + if (len < 0) + len = sizeof(pass) - 1; + } } sSMTP->command_state = smtp_command;