Bug #677378 - Crash in imapx_query_auth_types_sync()
authorMilan Crha <mcrha@redhat.com>
Wed, 21 Nov 2012 11:34:29 +0000 (12:34 +0100)
committerMilan Crha <mcrha@redhat.com>
Wed, 21 Nov 2012 11:34:29 +0000 (12:34 +0100)
camel/camel-imapx-server.c
camel/camel-imapx-store.c

index 26cf884..b000211 100644 (file)
@@ -2093,7 +2093,7 @@ imapx_untagged_ok_no_bad (CamelIMAPXServer *is,
                        is->priv->context->sinfo->u.cinfo = NULL;
                        if (cinfo)
                                imapx_free_capability (cinfo);
-                       c (is->tagprefix, "got capability flags %08x\n", is->cinfo->capa);
+                       c (is->tagprefix, "got capability flags %08x\n", is->cinfo ? is->cinfo->capa : 0xFFFFFFFF);
                }
                break;
        default:
@@ -3621,7 +3621,7 @@ imapx_connect_to_server (CamelIMAPXServer *is,
 
        if (method == CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT) {
 
-               if (!(is->cinfo->capa & IMAPX_CAPABILITY_STARTTLS)) {
+               if (is->cinfo && !(is->cinfo->capa & IMAPX_CAPABILITY_STARTTLS)) {
                        g_set_error (
                                &local_error, CAMEL_ERROR,
                                CAMEL_ERROR_GENERIC,
@@ -3655,7 +3655,7 @@ imapx_connect_to_server (CamelIMAPXServer *is,
                if (ic->status->condition == IMAPX_CAPABILITY) {
                        is->cinfo = ic->status->u.cinfo;
                        ic->status->u.cinfo = NULL;
-                       c (is->tagprefix, "got capability flags %08x\n", is->cinfo->capa);
+                       c (is->tagprefix, "got capability flags %08x\n", is->cinfo ? is->cinfo->capa : 0xFFFFFFFF);
                }
 
                camel_imapx_command_unref (ic);
@@ -3741,7 +3741,7 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
        g_object_unref (settings);
 
        if (mechanism != NULL) {
-               if (!g_hash_table_lookup (is->cinfo->auth_types, mechanism)) {
+               if (is->cinfo && !g_hash_table_lookup (is->cinfo->auth_types, mechanism)) {
                        g_set_error (
                                error, CAMEL_SERVICE_ERROR,
                                CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
@@ -3810,7 +3810,7 @@ camel_imapx_server_authenticate (CamelIMAPXServer *is,
                if (ic->status->condition == IMAPX_CAPABILITY) {
                        is->cinfo = ic->status->u.cinfo;
                        ic->status->u.cinfo = NULL;
-                       c (is->tagprefix, "got capability flags %08x\n", is->cinfo->capa);
+                       c (is->tagprefix, "got capability flags %08x\n", is->cinfo ? is->cinfo->capa : 0xFFFFFFFF);
                }
        }
 
@@ -3892,7 +3892,7 @@ imapx_reconnect (CamelIMAPXServer *is,
                imapx_init_idle (is);
 
        /* Fetch namespaces */
-       if (is->cinfo->capa & IMAPX_CAPABILITY_NAMESPACE) {
+       if (is->cinfo && (is->cinfo->capa & IMAPX_CAPABILITY_NAMESPACE) != 0) {
                ic = camel_imapx_command_new (
                        is, "NAMESPACE", NULL, "NAMESPACE");
                if (!imapx_command_run (is, ic, cancellable, error)) {
@@ -3903,7 +3903,7 @@ imapx_reconnect (CamelIMAPXServer *is,
                camel_imapx_command_unref (ic);
        }
 
-       if (use_qresync && is->cinfo->capa & IMAPX_CAPABILITY_QRESYNC) {
+       if (use_qresync && is->cinfo && (is->cinfo->capa & IMAPX_CAPABILITY_QRESYNC) != 0) {
                ic = camel_imapx_command_new (
                        is, "ENABLE", NULL, "ENABLE CONDSTORE QRESYNC");
                if (!imapx_command_run (is, ic, cancellable, error)) {
@@ -5238,7 +5238,7 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job,
                } else
                #endif
                {
-                       if (is->cinfo->capa & IMAPX_CAPABILITY_CONDSTORE)
+                       if (is->cinfo && (is->cinfo->capa & IMAPX_CAPABILITY_CONDSTORE) != 0)
                                ic = camel_imapx_command_new (
                                        is, "STATUS", NULL,
                                        "STATUS %f (MESSAGES UNSEEN UIDVALIDITY UIDNEXT HIGHESTMODSEQ)", folder);
index 94489db..d5d67f6 100644 (file)
@@ -296,7 +296,7 @@ imapx_query_auth_types_sync (CamelService *service,
                authtype = t->data;
                next = t->next;
 
-               if (!g_hash_table_lookup (server->cinfo->auth_types, authtype->authproto)) {
+               if (!server->cinfo || !g_hash_table_lookup (server->cinfo->auth_types, authtype->authproto)) {
                        sasl_types = g_list_remove_link (sasl_types, t);
                        g_list_free_1 (t);
                }
@@ -852,7 +852,7 @@ add_folders_to_summary (CamelIMAPXStore *istore,
                new_flags = (si->info.flags & (CAMEL_STORE_INFO_FOLDER_SUBSCRIBED | CAMEL_STORE_INFO_FOLDER_CHECK_FOR_NEW)) |
                                                (li->flags & ~CAMEL_STORE_INFO_FOLDER_SUBSCRIBED);
 
-               if (!(server->cinfo->capa & IMAPX_CAPABILITY_NAMESPACE))
+               if (server->cinfo && !(server->cinfo->capa & IMAPX_CAPABILITY_NAMESPACE))
                        istore->dir_sep = li->separator;
 
                if (si->info.flags != new_flags) {
@@ -979,7 +979,7 @@ fetch_folders_for_namespaces (CamelIMAPXStore *istore,
                        if (sync)
                                flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST;
 
-                       if (server->cinfo->capa & IMAPX_CAPABILITY_LIST_EXTENDED)
+                       if (server->cinfo && (server->cinfo->capa & IMAPX_CAPABILITY_LIST_EXTENDED) != 0)
                                list_ext = "RETURN (SUBSCRIBED)";
 
                        flags |= CAMEL_STORE_FOLDER_INFO_RECURSIVE;