talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 87b362fc337957c73b9ce0d4f7321674693a30ad
parent be36f031fa3f722c5dbce3dedb33429fadade08a
Author: wwp <wwp@free.fr>
Date:   Mon,  9 Jan 2017 11:37:18 +0100

Fixes Coverity CIDs: 1220388 1372362 1220222 1358399 1223756 1223757 1220305 1220269 1220243 1396991.

Diffstat:
Msrc/plugins/archive/archiver_gtk.c | 23+++++++++++++----------
Msrc/plugins/notification/notification_core.c | 8++++----
Msrc/plugins/notification/notification_trayicon.c | 2+-
Msrc/plugins/rssyl/opml_export.c | 2+-
Msrc/plugins/rssyl/rssyl_feed_props.c | 6++----
Msrc/plugins/rssyl/rssyl_parse_feed.c | 10++++++++--
Msrc/plugins/rssyl/rssyl_update_format.c | 8++++++--
Msrc/plugins/tnef_parse/tnef_parse.c | 18++++++++++++------
Msrc/plugins/vcalendar/day-view.c | 6+++---
Msrc/prefs_folder_item.c | 8+++++---
Msrc/prefs_gtk.c | 9+++------
11 files changed, 58 insertions(+), 42 deletions(-)

diff --git a/src/plugins/archive/archiver_gtk.c b/src/plugins/archive/archiver_gtk.c @@ -734,7 +734,10 @@ static void show_result(struct ArchivePage* page) { format = g_strdup("NO FORMAT"); } - g_stat(page->name, &st); + if (g_stat(page->name, &st) == -1) { + alertpanel_error("Could not get size of archive file '%s'.", page->name); + return; + } dialog = gtk_dialog_new_with_buttons( _("Archive result"), GTK_WINDOW(mainwin->window), @@ -849,17 +852,17 @@ static void show_result(struct ArchivePage* page) { STRING2, msg, -1); g_free(msg); - msg = g_strdup(gtk_entry_get_text(GTK_ENTRY(page->isoDate))); - if (msg) { - gtk_list_store_append(list, &iter); - gtk_list_store_set( - list, &iter, - STRING1, _("Select mails before"), - STRING2, msg, -1); - } + msg = g_strdup(gtk_entry_get_text(GTK_ENTRY(page->isoDate))); + if (msg) { + gtk_list_store_append(list, &iter); + gtk_list_store_set( + list, &iter, + STRING1, _("Select mails before"), + STRING2, msg, -1); + } g_free(msg); - gtk_window_set_default_size(GTK_WINDOW(dialog), 320, 260); + gtk_window_set_default_size(GTK_WINDOW(dialog), 320, 260); gtk_widget_show_all(dialog); } diff --git a/src/plugins/notification/notification_core.c b/src/plugins/notification/notification_core.c @@ -653,22 +653,22 @@ gchar* notification_libnotify_sanitize_str(gchar *in) i_out = 0; while(*in) { if(*in == '<') { - if(i_out+3 >= STR_MAX_LEN) break; + if(i_out+3 > STR_MAX_LEN) break; memcpy(&(tmp_str[i_out]),"&lt;",4); in++; i_out += 4; } else if(*in == '>') { - if(i_out+3 >= STR_MAX_LEN) break; + if(i_out+3 > STR_MAX_LEN) break; memcpy(&(tmp_str[i_out]),"&gt;",4); in++; i_out += 4; } else if(*in == '&') { - if(i_out+4 >= STR_MAX_LEN) break; + if(i_out+4 > STR_MAX_LEN) break; memcpy(&(tmp_str[i_out]),"&amp;",5); in++; i_out += 5; } else { - if(i_out >= STR_MAX_LEN) break; + if(i_out > STR_MAX_LEN) break; tmp_str[i_out++] = *in++; } } diff --git a/src/plugins/notification/notification_trayicon.c b/src/plugins/notification/notification_trayicon.c @@ -921,7 +921,7 @@ static gchar* notification_trayicon_popup_assemble_body(MsgInfo *msginfo) "%d new mail messages arrived", popup.num_mail), popup.num_mail); - tmp = g_strdup_printf("%s%s%s",utf8_str,str_empty?"":"\n",msg); + tmp = g_strdup_printf("%s%s%s",utf8_str,"",msg); g_free(msg); g_free(utf8_str); utf8_str = tmp; diff --git a/src/plugins/rssyl/opml_export.c b/src/plugins/rssyl/opml_export.c @@ -130,7 +130,7 @@ void rssyl_opml_export(void) log_warning(LOG_PROTOCOL, _("RSSyl: Couldn't delete old OPML file '%s': %s\n"), opmlfile, g_strerror(errno)); - debug_print("RSSyl: couldn't delete old file '%s'\n", opmlfile); + debug_print("RSSyl: Couldn't delete old file '%s'\n", opmlfile); g_free(opmlfile); return; } diff --git a/src/plugins/rssyl/rssyl_feed_props.c b/src/plugins/rssyl/rssyl_feed_props.c @@ -54,10 +54,8 @@ static void rssyl_gtk_prop_store(RFolderItem *ritem) url = (gchar *)gtk_entry_get_text(GTK_ENTRY(ritem->feedprop->url)); if( strlen(url) && strcmp(ritem->url, url)) { - if( ritem->url ) { - rssyl_passwd_set(ritem, NULL); - g_free(ritem->url); - } + rssyl_passwd_set(ritem, NULL); + g_free(ritem->url); ritem->url = g_strdup(url); } diff --git a/src/plugins/rssyl/rssyl_parse_feed.c b/src/plugins/rssyl/rssyl_parse_feed.c @@ -120,7 +120,10 @@ static void rssyl_expire_items(RFolderItem *ritem, Feed *feed) ctx->expired_ids = g_slist_prepend(ctx->expired_ids, g_strdup(feed_item_get_id(item))); fctx = (RFeedCtx *)item->data; - g_remove(fctx->path); + if (g_remove(fctx->path) != 0) { + debug_print("RSSyl: couldn't delete expiring item file '%s'\n", + fctx->path); + } } } @@ -137,7 +140,10 @@ static void rssyl_expire_items(RFolderItem *ritem, Feed *feed) feed_item_get_parent_id(item), (GCompareFunc)g_strcmp0)) { debug_print("RSSyl: expiring comment '%s'\n", feed_item_get_id(item)); fctx = (RFeedCtx *)item->data; - g_remove(fctx->path); + if (g_remove(fctx->path) != 0) { + debug_print("RSSyl: couldn't delete expiring comment file '%s'\n", + fctx->path); + } } } } diff --git a/src/plugins/rssyl/rssyl_update_format.c b/src/plugins/rssyl/rssyl_update_format.c @@ -227,7 +227,9 @@ void rssyl_update_format() g_free(ctx); - g_remove(old_feeds_xml); + if (g_remove(old_feeds_xml) != 0) { + debug_print("RSSyl: Couldn't delete '%s'\n", old_feeds_xml); + } g_free(old_feeds_xml); } @@ -267,7 +269,9 @@ static void rssyl_update_format_move_contents(FolderItem *olditem, move_file(fpath, nfpath, FALSE); g_free(nfpath); } - g_remove(fpath); + if (g_remove(fpath) != 0) { + debug_print("RSSyl: (FORMAT) couldn't delete '%s'\n", fpath); + } g_free(fpath); } diff --git a/src/plugins/tnef_parse/tnef_parse.c b/src/plugins/tnef_parse/tnef_parse.c @@ -236,6 +236,7 @@ MimeInfo *tnef_parse_vcard(TNEFStruct *tnef) FILE *fp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename); GStatBuf statbuf; gboolean result = FALSE; + gint ret; if (!fp) { g_free(tmpfilename); return NULL; @@ -252,16 +253,21 @@ MimeInfo *tnef_parse_vcard(TNEFStruct *tnef) result = SaveVCard(fp, tnef); fclose(fp); - g_stat(tmpfilename, &statbuf); - sub_info->tmp = TRUE; - sub_info->length = statbuf.st_size; - sub_info->encoding_type = ENC_BINARY; - - if (!result) { + + ret = g_stat(tmpfilename, &statbuf); + if (ret == -1) { + debug_printf("couldn't stat tmpfilename '%s'\n", tmpfilename); + } + + if ((ret == -1) || !result) { claws_unlink(tmpfilename); procmime_mimeinfo_free_all(&sub_info); return tnef_broken_mimeinfo(_("Failed to parse VCard data.")); } + + sub_info->tmp = TRUE; + sub_info->length = statbuf.st_size; + sub_info->encoding_type = ENC_BINARY; return sub_info; } diff --git a/src/plugins/vcalendar/day-view.c b/src/plugins/vcalendar/day-view.c @@ -240,7 +240,7 @@ static void dw_summary_selected(GtkCMCTree *ctree, GtkCMCTreeNode *row, localtime_r(&t_start, &tm_start); if (tm_start.tm_hour > 2) gtk_adjustment_set_value(v_adj, - (v_adj->upper-v_adj->page_size)/(24/(tm_start.tm_hour-2))); + ((v_adj->upper-v_adj->page_size)/(gdouble)(24/(tm_start.tm_hour-2)))); else gtk_adjustment_set_value(v_adj, 0); gtk_adjustment_changed(v_adj); @@ -264,7 +264,7 @@ static void day_view_new_meeting_cb(day_win *dw, gpointer data_i, gpointer data_ || ((tm_date.tm_year%400) == 0))) monthdays[1] = 29; - if (offset_d > monthdays[mon]) { + if (offset_d > (int)monthdays[mon]) { while (tm_date.tm_mday > 1) orage_move_day(&tm_date, 1); offset_d -= monthdays[mon]; @@ -814,7 +814,7 @@ static void build_day_view_table(day_win *dw) gtk_table_attach(GTK_TABLE(dw->dtable_h), button, i, i+1, 0, 1 , (GTK_FILL), (0), 0, 0); - if (++tm_date.tm_mday == (monthdays[tm_date.tm_mon]+1)) { + if (++tm_date.tm_mday == (int)(monthdays[tm_date.tm_mon]+1)) { if (++tm_date.tm_mon == 12) { ++tm_date.tm_year; tm_date.tm_mon = 0; diff --git a/src/prefs_folder_item.c b/src/prefs_folder_item.c @@ -1762,9 +1762,11 @@ static void folder_regexp_test_cb(GtkWidget *widget, gpointer data) #if !GTK_CHECK_VERSION(3, 0, 0) if (!colors_initialised) { - gdk_color_parse("#ff7070", &red); - colors_initialised = gdk_colormap_alloc_color( - gdk_colormap_get_system(), &red, FALSE, TRUE); + if (!gdk_color_parse("#ff7070", &red)) { + g_warning("color parse failed: red"); + colors_initialised = gdk_colormap_alloc_color( + gdk_colormap_get_system(), &red, FALSE, TRUE); + } } #endif diff --git a/src/prefs_gtk.c b/src/prefs_gtk.c @@ -448,8 +448,7 @@ void prefs_set_default(PrefParam *param) if (!g_ascii_strcasecmp(param[i].defval, "TRUE")) *((gboolean *)param[i].data) = TRUE; else - *((gboolean *)param[i].data) = - atoi(param[i].defval) ? TRUE : FALSE; + *((gboolean *)param[i].data) = atoi(param[i].defval) ? TRUE : FALSE; } else *((gboolean *)param[i].data) = FALSE; break; @@ -462,15 +461,13 @@ void prefs_set_default(PrefParam *param) break; case P_USHORT: if (param[i].defval != NULL) - *((gushort *)param[i].data) = - (gushort)atoi(param[i].defval); + *((gushort *)param[i].data) = (gushort)atoi(param[i].defval); else *((gushort *)param[i].data) = 0; break; case P_COLOR: if (param[i].defval != NULL && gdk_color_parse(param[i].defval, &color)) - *((gulong *)param[i].data) = - RGB_FROM_GDK_COLOR(color); + *((gulong *)param[i].data) = RGB_FROM_GDK_COLOR(color); else if (param[i].defval) /* be compatible and accept ints */ *((gulong *)param[i].data) = strtoul(param[i].defval, 0, 10);