From 63a61517ff2c94c54ff4d071cbd406d135d895d0 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Mon, 1 Sep 2014 01:41:32 +0200 Subject: [PATCH] Base64: we need the length of the string; else we fail --- citadel/modules/managesieve/serv_managesieve.c | 4 ++-- citadel/modules/smtp/serv_smtp.c | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/citadel/modules/managesieve/serv_managesieve.c b/citadel/modules/managesieve/serv_managesieve.c index 4fa99a72a..7158f4c00 100644 --- a/citadel/modules/managesieve/serv_managesieve.c +++ b/citadel/modules/managesieve/serv_managesieve.c @@ -276,10 +276,10 @@ void cmd_mgsve_auth(int num_parms, char **parms, struct sdm_userdata *u) message = ReadString(GetSizeToken(parms[2]), parms[0]); if (message != NULL) {/**< do we have tokenized login? */ - CtdlDecodeBase64(auth, MGSVE->transmitted_message, SIZ); + CtdlDecodeBase64(auth, MGSVE->transmitted_message, strlen(MGSVE->transmitted_message)); } else - CtdlDecodeBase64(auth, parms[2], SIZ); + CtdlDecodeBase64(auth, parms[2], strlen(parms[2])); username = auth; if ((*username == '\0') && (*(username + 1) != '\0')) username ++; diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index 892d8e7a7..eddad6be7 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -394,12 +394,12 @@ void smtp_help(long offset, long Flags) { void smtp_get_user(long offset) { char buf[SIZ]; - char username[SIZ]; citsmtp *sSMTP = SMTP; - CtdlDecodeBase64(username, ChrPtr(sSMTP->Cmd) + offset, SIZ); + StrBufDecodeBase64(sSMTP->Cmd); + /* syslog(LOG_DEBUG, "Trying <%s>\n", username); */ - if (CtdlLoginExistingUser(NULL, username) == login_ok) { + if (CtdlLoginExistingUser(NULL, ChrPtr(sSMTP->Cmd)) == login_ok) { CtdlEncodeBase64(buf, "Password:", 9, 0); cprintf("334 %s\r\n", buf); sSMTP->command_state = smtp_password; @@ -418,12 +418,11 @@ void smtp_get_pass(long offset, long Flags) { citsmtp *sSMTP = SMTP; char password[SIZ]; - long len; - memset(password, 0, sizeof(password)); - len = CtdlDecodeBase64(password, ChrPtr(sSMTP->Cmd), SIZ); + memset(password, 0, sizeof(password)); + StrBufDecodeBase64(sSMTP->Cmd); /* syslog(LOG_DEBUG, "Trying <%s>\n", password); */ - if (CtdlTryPassword(password, len) == pass_ok) { + if (CtdlTryPassword(SKEY(sSMTP->Cmd)) == pass_ok) { smtp_auth_greeting(offset, Flags); } else { -- 2.30.2