Fix null pointer dereferences and missing return checks
authorColin Leroy <colin@colino.net>
Thu, 8 Oct 2015 17:16:52 +0000 (19:16 +0200)
committerColin Leroy <colin@colino.net>
Thu, 8 Oct 2015 17:16:52 +0000 (19:16 +0200)
src/etpan/imap-thread.c
src/gtk/gtkcmclist.c
src/imap.c

index f1c555d..ffe0598 100644 (file)
@@ -935,6 +935,9 @@ int imap_threaded_login(Folder * folder,
        
        debug_print("imap login - begin\n");
        
+       if (!folder)
+               return MAILIMAP_ERROR_INVAL;
+
        param.imap = get_imap(folder);
        param.login = login;
        param.password = password;
index 737b278..e58f8c5 100644 (file)
@@ -7417,7 +7417,9 @@ gtk_cmclist_merge (GtkCMCList *clist,
        }
     }
 
-  z.next->prev = NULL;
+  if (z.next)
+       z.next->prev = NULL;
+
   return z.next;
 }
 
index ad476ff..79b1a89 100644 (file)
@@ -2000,8 +2000,11 @@ static gint imap_do_copy_msgs(Folder *folder, FolderItem *dest,
                                if (!is_dir_exist(cache_path))
                                        make_dir_hier(cache_path);
                                if (is_file_exist(real_file) && is_dir_exist(cache_path)) {
-                                       copy_file(real_file, cache_file, TRUE);
-                                       debug_print("copied to cache: %s\n", cache_file);
+                                       if (copy_file(real_file, cache_file, TRUE) < 0)
+                                               debug_print("couldn't cache to %s: %s\n", cache_file,
+                                                           strerror(errno));
+                                       else
+                                               debug_print("copied to cache: %s\n", cache_file);
                                }
                                g_free(real_file);
                                g_free(cache_file);