talons

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

commit 9ff86db84bc2fdee00d1379fa875d2e6d9e48c2d
parent 45a6494a22ca888132efbf5f2096e57fd0fb1970
Author: Andrej Kacian <andrej@kacian.sk>
Date:   Tue,  1 Jul 2014 19:14:47 +0200

RSSyl: more fixes for Coverity issues

Diffstat:
Msrc/plugins/rssyl/libfeed/date.c | 5+++--
Msrc/plugins/rssyl/libfeed/feeditem.c | 5++++-
Msrc/plugins/rssyl/libfeed/parser_atom10.c | 5+++++
Msrc/plugins/rssyl/rssyl_add_item.c | 10+++++++---
Msrc/plugins/rssyl/rssyl_update_comments.c | 1+
Msrc/plugins/rssyl/rssyl_update_feed.c | 9++++++---
6 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/plugins/rssyl/libfeed/date.c b/src/plugins/rssyl/libfeed/date.c @@ -48,8 +48,9 @@ time_t parseISO8601Date(gchar *date) { time_t t, t2, offset = 0; gboolean success = FALSE; gchar *pos; - - g_assert(date != NULL); + + if (date == NULL) + return -1; memset(&tm, 0, sizeof(struct tm)); diff --git a/src/plugins/rssyl/libfeed/feeditem.c b/src/plugins/rssyl/libfeed/feeditem.c @@ -352,7 +352,10 @@ FeedItem *feed_item_copy(FeedItem *item) nitem->id_is_permalink = item->id_is_permalink; nitem->xhtml_content = item->xhtml_content; - nitem->data = g_memdup(item->data, sizeof(item->data)); + /* We have no way of knowing the size of object item->data is pointing + * to, so we can not reliably copy it to the new item. Caller will have + * to take care of that itself. */ + nitem->data = NULL; return nitem; } diff --git a/src/plugins/rssyl/libfeed/parser_atom10.c b/src/plugins/rssyl/libfeed/parser_atom10.c @@ -51,6 +51,11 @@ void feed_parser_atom10_start(void *data, const gchar *el, const gchar **attr) } else if( ctx->depth == 2 ) { + /* This should only happen with malformed atom feeds - we're in + * XML depth 2, but not inside an <entry> block. */ + if (ctx->curitem == NULL) + return; + if( !strcmp(el, "author") ) { /* Start of author info for current feed item. * Set correct location. */ diff --git a/src/plugins/rssyl/rssyl_add_item.c b/src/plugins/rssyl/rssyl_add_item.c @@ -373,11 +373,15 @@ void rssyl_add_item(RFolderItem *ritem, FeedItem *feed_item) dirname = folder_item_get_path(&ritem->item); template = g_strconcat(dirname, G_DIR_SEPARATOR_S, RSSYL_TMP_TEMPLATE, NULL); - fd = mkstemp(template); + if ((fd = mkstemp(template)) < 0) { + g_warning("Couldn't mkstemp('%s'), not adding message!\n", template); + g_free(template); + return; + } f = fdopen(fd, "w"); - if(f == NULL) { - g_warning("Couldn't open file '%s', not adding msg!\n", template); + if (f == NULL) { + g_warning("Couldn't open file '%s', not adding message!\n", template); g_free(template); return; } diff --git a/src/plugins/rssyl/rssyl_update_comments.c b/src/plugins/rssyl/rssyl_update_comments.c @@ -85,6 +85,7 @@ void rssyl_update_comments(RFolderItem *ritem) closedir(dp); g_free(path); debug_print("RSSyl: bailing out, app is exiting\n"); + return; } if( (num = to_number(d->d_name)) > 0 && d->d_type == DT_REG ) { diff --git a/src/plugins/rssyl/rssyl_update_feed.c b/src/plugins/rssyl/rssyl_update_feed.c @@ -61,7 +61,7 @@ static void *rssyl_fetch_feed_thr(void *arg) } /* rssyl_fetch_feed() */ -RFetchCtx *rssyl_fetch_feed(RFetchCtx *ctx, gboolean verbose) +void rssyl_fetch_feed(RFetchCtx *ctx, gboolean verbose) { #ifdef USE_PTHREAD pthread_t pt; @@ -127,13 +127,16 @@ RFetchCtx *rssyl_fetch_feed(RFetchCtx *ctx, gboolean verbose) ctx->success = FALSE; } else { - if( ctx->feed == NULL || feed_get_title(ctx->feed) == NULL ) { + if( feed_get_title(ctx->feed) == NULL ) { /* libcurl was happy, but libfeed wasn't */ debug_print("RSSyl: Error reading feed\n"); if( verbose ) alertpanel_error(_("No valid feed found at\n<b>%s</b>"), feed_get_url(ctx->feed)); - log_error(LOG_PROTOCOL, RSSYL_LOG_ERROR_NOFEED, ctx->feed->url); + + log_error(LOG_PROTOCOL, RSSYL_LOG_ERROR_NOFEED, + feed_get_url(ctx->feed)); + ctx->success = FALSE; } }