[evolution-data-server] Bug #682322 - SIGSEGV in pop3_folder_refresh_info_sync



commit ed65569413c3f9eeb068650730b1f402ddf6fa48
Author: Milan Crha <mcrha redhat com>
Date:   Wed Jun 26 18:59:31 2013 +0200

    Bug #682322 - SIGSEGV in pop3_folder_refresh_info_sync

 camel/providers/pop3/camel-pop3-folder.c |    4 ++-
 camel/providers/pop3/camel-pop3-store.c  |   39 +++++++++++++++++++++++++----
 2 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index 96d45fa..2395c12 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -169,6 +169,8 @@ cmd_list (CamelPOP3Engine *pe,
        CamelSettings *settings;
        gint batch_fetch_count;
 
+       g_return_if_fail (pe != NULL);
+
        parent_store = camel_folder_get_parent_store (folder);
        pop3_folder = (CamelPOP3Folder *) folder;
        service = (CamelService *) parent_store;
@@ -754,7 +756,7 @@ pop3_folder_refresh_info_sync (CamelFolder *folder,
                cmd_list, folder,
                cancellable, &local_error,
                "LIST\r\n");
-       if (!local_error && (pop3_engine->capa & CAMEL_POP3_CAP_UIDL) != 0)
+       if (!local_error && pop3_engine && (pop3_engine->capa & CAMEL_POP3_CAP_UIDL) != 0)
                pcu = camel_pop3_engine_command_new (
                        pop3_engine,
                        CAMEL_POP3_COMMAND_MULTI,
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index e5d2d1d..5aa226b 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -284,6 +284,15 @@ try_sasl (CamelPOP3Store *store,
        g_object_unref (settings);
 
        pop3_engine = camel_pop3_store_ref_engine (store);
+       if (!pop3_engine) {
+               g_set_error_literal (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                       _("You must be working online to complete this operation"));
+               result = CAMEL_AUTHENTICATION_ERROR;
+               goto exit;
+       }
+
        pop3_stream = pop3_engine->stream;
 
        sasl = camel_sasl_new ("pop", mechanism, service);
@@ -540,10 +549,18 @@ pop3_store_connect_sync (CamelService *service,
        /* Now that we are in the TRANSACTION state,
         * try regetting the capabilities */
        pop3_engine = camel_pop3_store_ref_engine (store);
-       pop3_engine->state = CAMEL_POP3_ENGINE_TRANSACTION;
-       if (!camel_pop3_engine_reget_capabilities (pop3_engine, cancellable, error))
+       if (pop3_engine) {
+               pop3_engine->state = CAMEL_POP3_ENGINE_TRANSACTION;
+               if (!camel_pop3_engine_reget_capabilities (pop3_engine, cancellable, error))
+                       success = FALSE;
+               g_clear_object (&pop3_engine);
+       } else {
+               g_set_error_literal (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                       _("You must be working online to complete this operation"));
                success = FALSE;
-       g_clear_object (&pop3_engine);
+       }
 
 exit:
        g_free (mechanism);
@@ -622,6 +639,14 @@ pop3_store_authenticate_sync (CamelService *service,
        g_object_unref (settings);
 
        pop3_engine = camel_pop3_store_ref_engine (store);
+       if (!pop3_engine) {
+               g_set_error_literal (
+                       error, CAMEL_SERVICE_ERROR,
+                       CAMEL_SERVICE_ERROR_UNAVAILABLE,
+                       _("You must be working online to complete this operation"));
+               result = CAMEL_AUTHENTICATION_ERROR;
+               goto exit;
+       }
 
        if (mechanism == NULL) {
                if (password == NULL) {
@@ -780,10 +805,12 @@ pop3_store_query_auth_types_sync (CamelService *service,
 
                pop3_engine = camel_pop3_store_ref_engine (store);
 
-               types = g_list_concat (types, g_list_copy (pop3_engine->auth));
-               pop3_store_disconnect_sync (service, TRUE, cancellable, NULL);
+               if (pop3_engine) {
+                       types = g_list_concat (types, g_list_copy (pop3_engine->auth));
+                       pop3_store_disconnect_sync (service, TRUE, cancellable, NULL);
 
-               g_clear_object (&pop3_engine);
+                       g_clear_object (&pop3_engine);
+               }
        }
 
        return types;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]