From 0a708b4e41e80263f8c8e4a5a399c69cec1608c6 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Sun, 18 Mar 2018 17:07:51 +0100 Subject: Use the mpes1: - tag for passwords encrypted with master password --- libsylph/imap.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'libsylph/imap.c') diff --git a/libsylph/imap.c b/libsylph/imap.c index e773ad4..e1c7cfd 100644 --- a/libsylph/imap.c +++ b/libsylph/imap.c @@ -707,8 +707,12 @@ static gint imap_session_connect(IMAPSession *session) log_message(_("creating IMAP4 connection to %s:%d ...\n"), SESSION(session)->server, SESSION(session)->port); - /* TODO: check of the format is correct | possible memory leak */ - pass = decrypt_with_master_password(account->passwd); + if (master_password_active()) { + pass = decrypt_with_master_password(account->passwd); + /* a new string is allocated. To be removed ... */ + } else { + pass = account->passwd; + } if (!pass) pass = account->tmp_pass; if (!pass) { @@ -771,8 +775,11 @@ static gint imap_session_connect(IMAPSession *session) #endif if (!session->authenticated && - imap_auth(session, account->userid, pass, account->imap_auth_type) - != IMAP_SUCCESS) { + imap_auth(session, account->userid, pass, account->imap_auth_type) + != IMAP_SUCCESS) { + if (master_password_active()) { + g_free(pass); /* remove the decrypted password */ + } if (account->tmp_pass) { g_free(account->tmp_pass); account->tmp_pass = NULL; @@ -781,6 +788,10 @@ static gint imap_session_connect(IMAPSession *session) return IMAP_AUTHFAIL; } + if (master_password_active()) { + g_free(pass); /* remove the decrypted password */ + } + return IMAP_SUCCESS; } -- cgit v1.3