2008-05-16 [colin] 3.4.0cvs47
authorColin Leroy <colin@colino.net>
Fri, 16 May 2008 15:53:31 +0000 (15:53 +0000)
committerColin Leroy <colin@colino.net>
Fri, 16 May 2008 15:53:31 +0000 (15:53 +0000)
* src/imap.c
Fix another possible crash (on fatal errors
at login, like stream error).

ChangeLog
PATCHSETS
configure.ac
src/imap.c

index a057de7..c7d083d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-16 [colin]     3.4.0cvs47
+
+       * src/imap.c
+               Fix another possible crash (on fatal errors
+               at login, like stream error).
+
 2008-05-16 [paul]      3.4.0cvs46
 
        * tools/thunderbird-filters-convertor.pl
index 509d81e..473e0c8 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.654.2.3400 -r 1.654.2.3401 configure.ac;  cvs diff -u -r 1.1.2.19 -r 1.1.2.20 src/ldapupdate.c;  ) > 3.4.0cvs44.patchset
 ( cvs diff -u -r 1.30.2.28 -r 1.30.2.29 tools/README;  cvs diff -u -r 1.1.2.2 -r 1.1.2.3 tools/csv2addressbook.pl;  ) > 3.4.0cvs45.patchset
 ( cvs diff -u -r 1.1.2.2 -r 1.1.2.3 tools/thunderbird-filters-convertor.pl;  ) > 3.4.0cvs46.patchset
+( cvs diff -u -r 1.179.2.219 -r 1.179.2.220 src/imap.c;  ) > 3.4.0cvs47.patchset
index 40c01a6..6bb7fd5 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=4
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=46
+EXTRA_VERSION=47
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 986dc33..eb11efb 100644 (file)
@@ -188,7 +188,7 @@ static void  imap_folder_destroy    (Folder         *folder);
 
 static IMAPSession *imap_session_new   (Folder         *folder,
                                         const PrefsAccount     *account);
-static void    imap_session_authenticate(IMAPSession           *session,
+static gint    imap_session_authenticate(IMAPSession           *session,
                                          const PrefsAccount    *account);
 static void    imap_session_destroy    (Session        *session);
 
@@ -971,14 +971,16 @@ static IMAPSession *imap_session_get(Folder *folder)
 
        /* Make sure session is authenticated */
        if (!IMAP_SESSION(session)->authenticated)
-               imap_session_authenticate(IMAP_SESSION(session), folder->account);
+               r = imap_session_authenticate(IMAP_SESSION(session), folder->account);
        
-       if (!IMAP_SESSION(session)->authenticated) {
-               imap_threaded_disconnect(session->folder);
+       if (r != MAILIMAP_NO_ERROR || (!is_fatal(r) && !IMAP_SESSION(session)->authenticated)) {
                rfolder->session = NULL;
-               SESSION(session)->state = SESSION_DISCONNECTED;
-               SESSION(session)->sock = NULL;
-               session_destroy(SESSION(session));
+               if (!is_fatal(r)) {
+                       imap_threaded_disconnect(session->folder);
+                       SESSION(session)->state = SESSION_DISCONNECTED;
+                       SESSION(session)->sock = NULL;
+                       session_destroy(SESSION(session));
+               }
                rfolder->last_failure = time(NULL);
                rfolder->connecting = FALSE;
                return NULL;
@@ -1148,12 +1150,12 @@ static IMAPSession *imap_session_new(Folder * folder,
        return session;
 }
 
-static void imap_session_authenticate(IMAPSession *session, 
+static gint imap_session_authenticate(IMAPSession *session, 
                                      const PrefsAccount *account)
 {
        gchar *pass, *acc_pass;
        gboolean failed = FALSE;
-
+       gint ok = MAILIMAP_NO_ERROR;
        g_return_if_fail(account->userid != NULL);
        acc_pass = account->passwd;
 try_again:
@@ -1162,18 +1164,18 @@ try_again:
                gchar *tmp_pass;
                tmp_pass = input_dialog_query_password(account->recv_server, account->userid);
                if (!tmp_pass)
-                       return;
-               Xstrdup_a(pass, tmp_pass, {g_free(tmp_pass); return;});
+                       return MAILIMAP_NO_ERROR;
+               Xstrdup_a(pass, tmp_pass, {g_free(tmp_pass); return MAILIMAP_NO_ERROR;});
                g_free(tmp_pass);
        } else if (account->imap_auth_type == IMAP_AUTH_ANON) {
                pass = "";
        }
        statuswindow_print_all(_("Connecting to IMAP4 server %s...\n"),
                                account->recv_server);
-       if (imap_auth(session, account->userid, pass, account->imap_auth_type) != MAILIMAP_NO_ERROR) {
+       if ((ok = imap_auth(session, account->userid, pass, account->imap_auth_type)) != MAILIMAP_NO_ERROR) {
                statusbar_pop_all();
                
-               if (!failed) {
+               if (!failed && !is_fatal(ok)) {
                        acc_pass = NULL;
                        failed = TRUE;
                        goto try_again;
@@ -1185,12 +1187,12 @@ try_again:
                                alertpanel_error_log(_("Couldn't login to IMAP server %s."), account->recv_server);
                }               
 
-               return;
+               return ok;
        } 
 
        statuswindow_pop_all();
        session->authenticated = TRUE;
-       return;
+       return MAILIMAP_NO_ERROR;
 }
 
 static void imap_session_destroy(Session *session)