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;
{
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 {
void smtp_try_plain(long offset, long Flags)
{
citsmtp *sSMTP = SMTP;
- char decoded_authstring[1024];
- char ident[256];
- char user[256];
- char pass[256];
+ const char*decoded_authstring;
+ char ident[256] = "";
+ char user[256] = "";
+ char pass[256] = "";
int result;
- long len;
- CtdlDecodeBase64(decoded_authstring, ChrPtr(sSMTP->Cmd), StrLength(sSMTP->Cmd));
- safestrncpy(ident, decoded_authstring, sizeof ident);
- safestrncpy(user, &decoded_authstring[strlen(ident) + 1], sizeof user);
- len = safestrncpy(pass, &decoded_authstring[strlen(ident) + strlen(user) + 2], sizeof pass);
- if (len == -1)
- len = sizeof(pass) - 1;
+ long decoded_len;
+ long len = 0;
+ long plen = 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;
+
+ if (decoded_len > 0)
+ {
+ len = safestrncpy(user, decoded_authstring, sizeof user);
+
+ decoded_authstring += len + 1;
+ decoded_len -= len - 1;
+ }
+
+ if (decoded_len > 0)
+ {
+ plen = safestrncpy(pass, decoded_authstring, sizeof pass);
+
+ if (plen < 0)
+ plen = sizeof(pass) - 1;
+ }
+ }
sSMTP->command_state = smtp_command;
}
if (result == login_ok) {
- if (CtdlTryPassword(pass, len) == pass_ok) {
+ if (CtdlTryPassword(pass, plen) == pass_ok) {
smtp_webcit_preferences_hack();
smtp_auth_greeting(offset, Flags);
return;