Coverity fixes
authorColin Leroy <colin@colino.net>
Fri, 6 Jun 2014 13:27:33 +0000 (15:27 +0200)
committerColin Leroy <colin@colino.net>
Fri, 6 Jun 2014 13:27:33 +0000 (15:27 +0200)
src/mainwindow.c
src/plugins/bogofilter/bogofilter.c
src/plugins/pgpcore/select-keys.c
src/plugins/pgpcore/sgpgme.c
src/plugins/pgpinline/pgpinline.c
src/plugins/pgpmime/pgpmime.c
src/procmime.c
src/procmsg.c
src/procmsg.h
src/summaryview.c
src/textview.c

index 46de25b6e6e9064b45e65a434d113a8b4a2da7f9..dffcd3bec4d807cd73a7e86f078e7c13ecb50170 100644 (file)
@@ -1241,7 +1241,7 @@ static gint mainwin_tag_cmp_list(gconstpointer a, gconstpointer b)
                return tag_b == NULL ? 0:1;
        
        if (tag_b == NULL)
                return tag_b == NULL ? 0:1;
        
        if (tag_b == NULL)
-               return tag_a == 1;
+               return 1;
  
        return g_utf8_collate(tag_a, tag_b);
 }
  
        return g_utf8_collate(tag_a, tag_b);
 }
index 726fca4521eddd17c7a09c99684d8f6647422f6c..f97d69ae52e06b665a405d15c668112689838a30 100644 (file)
@@ -263,6 +263,8 @@ static void bogofilter_do_filter(BogoFilterData *data)
                                        data->new_hams = g_slist_prepend(data->new_hams, msginfo);
                                } else {
                                        gchar **parts = NULL;
                                        data->new_hams = g_slist_prepend(data->new_hams, msginfo);
                                } else {
                                        gchar **parts = NULL;
+
+                                       buf[sizeof(buf - 1)] = '\0';
                                        if (strchr(buf, '/')) {
                                                tmp = strrchr(buf, '/')+1;
                                        } else {
                                        if (strchr(buf, '/')) {
                                                tmp = strrchr(buf, '/')+1;
                                        } else {
@@ -284,7 +286,7 @@ static void bogofilter_do_filter(BogoFilterData *data)
                                                        fclose (input);
                                                else if (!input && output)
                                                        fclose (output);
                                                        fclose (input);
                                                else if (!input && output)
                                                        fclose (output);
-                                               else {
+                                               else if (input && output) {
                                                        gchar tmpbuf[BUFFSIZE];
                                                        gboolean err = FALSE;
                                                        const gchar *bogosity = *parts[1] == 'S' ? "Spam":
                                                        gchar tmpbuf[BUFFSIZE];
                                                        gboolean err = FALSE;
                                                        const gchar *bogosity = *parts[1] == 'S' ? "Spam":
@@ -742,6 +744,7 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
        gchar *file = NULL;
        const gchar *bogo_exec = (config.bogopath && *config.bogopath) ? config.bogopath:"bogofilter";
        gint status = 0;
        gchar *file = NULL;
        const gchar *bogo_exec = (config.bogopath && *config.bogopath) ? config.bogopath:"bogofilter";
        gint status = 0;
+
        if (msginfo == NULL && msglist == NULL) {
                return -1;
        }
        if (msginfo == NULL && msglist == NULL) {
                return -1;
        }
@@ -771,10 +774,8 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                        g_free(file);
                        if (message_callback != NULL)
                                message_callback(NULL, 0, 0, FALSE);
                        g_free(file);
                        if (message_callback != NULL)
                                message_callback(NULL, 0, 0, FALSE);
-                       return 0;
                }
                }
-       }
-       if (msglist) {
+       } else if (msglist) {
                GSList *cur = msglist;
                MsgInfo *info;
                int total = g_slist_length(msglist);
                GSList *cur = msglist;
                MsgInfo *info;
                int total = g_slist_length(msglist);
@@ -881,9 +882,8 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
 
                if (message_callback != NULL)
                        message_callback(NULL, 0, 0, FALSE);
 
                if (message_callback != NULL)
                        message_callback(NULL, 0, 0, FALSE);
-               return 0;
        }
        }
-       return -1;
+       return 0;
 }
 
 void bogofilter_save_config(void)
 }
 
 void bogofilter_save_config(void)
index 423675c294e5881427810a050729ed0cb8695c8c..65592207ed05e76f52fbc5f913edbfc4614b94fc 100644 (file)
@@ -128,7 +128,7 @@ gpgmegtk_recipient_selection (GSList *recp_names, SelectionResult *result,
        sk.proto = proto;
         gtk_cmclist_clear (sk.clist);
         key = fill_clist (&sk, sk.pattern, proto);
        sk.proto = proto;
         gtk_cmclist_clear (sk.clist);
         key = fill_clist (&sk, sk.pattern, proto);
-        update_progress (&sk, 0, sk.pattern);
+        update_progress (&sk, 0, sk.pattern ? sk.pattern : "NULL");
        if (!key) {
                gtk_widget_show_all (sk.window);
                gtk_main ();
        if (!key) {
                gtk_widget_show_all (sk.window);
                gtk_main ();
index d30ef72301d839c4888597a3145c79403f592104..dd26197d1be26d8a826523572e88d23496118a3f 100644 (file)
@@ -619,19 +619,23 @@ void sgpgme_init()
 #else
                ctype_locale = g_strdup(setlocale(LC_CTYPE, NULL));
 #endif
 #else
                ctype_locale = g_strdup(setlocale(LC_CTYPE, NULL));
 #endif
-               debug_print("setting gpgme locale to: %s\n", ctype_locale ? ctype_locale : "NULL");
-               if (strchr(ctype_locale, '.'))
-                       *(strchr(ctype_locale, '.')) = '\0';
-               else if (strchr(ctype_locale, '@'))
-                       *(strchr(ctype_locale, '@')) = '\0';
-               ctype_utf8_locale = g_strconcat(ctype_locale, ".UTF-8", NULL);
-
-               debug_print("setting gpgme locale to UTF8: %s\n", ctype_utf8_locale ? ctype_utf8_locale : "NULL");
-               gpgme_set_locale(NULL, LC_CTYPE, ctype_utf8_locale);
-
-               debug_print("done\n");
-               g_free(ctype_utf8_locale);
-               g_free(ctype_locale);
+               if (ctype_locale) {
+                       debug_print("setting gpgme CTYPE locale to: %s\n", ctype_locale);
+                       if (strchr(ctype_locale, '.'))
+                               *(strchr(ctype_locale, '.')) = '\0';
+                       else if (strchr(ctype_locale, '@'))
+                               *(strchr(ctype_locale, '@')) = '\0';
+                       ctype_utf8_locale = g_strconcat(ctype_locale, ".UTF-8", NULL);
+
+                       debug_print("setting gpgme locale to UTF8: %s\n", ctype_utf8_locale ? ctype_utf8_locale : "NULL");
+                       gpgme_set_locale(NULL, LC_CTYPE, ctype_utf8_locale);
+
+                       debug_print("done\n");
+                       g_free(ctype_utf8_locale);
+                       g_free(ctype_locale);
+               } else {
+                       debug_print("couldn't set gpgme CTYPE locale\n");
+               }
 #endif
 #ifdef LC_MESSAGES
                debug_print("setting gpgme MESSAGES locale\n");
 #endif
 #ifdef LC_MESSAGES
                debug_print("setting gpgme MESSAGES locale\n");
@@ -640,19 +644,23 @@ void sgpgme_init()
 #else
                messages_locale = g_strdup(setlocale(LC_MESSAGES, NULL));
 #endif
 #else
                messages_locale = g_strdup(setlocale(LC_MESSAGES, NULL));
 #endif
-               debug_print("setting gpgme locale to: %s\n", messages_locale ? messages_locale : "NULL");
-               if (strchr(messages_locale, '.'))
-                       *(strchr(messages_locale, '.')) = '\0';
-               else if (strchr(messages_locale, '@'))
-                       *(strchr(messages_locale, '@')) = '\0';
-               messages_utf8_locale = g_strconcat(messages_locale, ".UTF-8", NULL);
-               debug_print("setting gpgme locale to UTF8: %s\n", messages_utf8_locale ? messages_utf8_locale : "NULL");
-
-               gpgme_set_locale(NULL, LC_MESSAGES, messages_utf8_locale);
-
-               debug_print("done\n");
-               g_free(messages_utf8_locale);
-               g_free(messages_locale);
+               if (messages_locale) {
+                       debug_print("setting gpgme MESSAGES locale to: %s\n", messages_locale);
+                       if (strchr(messages_locale, '.'))
+                               *(strchr(messages_locale, '.')) = '\0';
+                       else if (strchr(messages_locale, '@'))
+                               *(strchr(messages_locale, '@')) = '\0';
+                       messages_utf8_locale = g_strconcat(messages_locale, ".UTF-8", NULL);
+                       debug_print("setting gpgme locale to UTF8: %s\n", messages_utf8_locale ? messages_utf8_locale : "NULL");
+
+                       gpgme_set_locale(NULL, LC_MESSAGES, messages_utf8_locale);
+
+                       debug_print("done\n");
+                       g_free(messages_utf8_locale);
+                       g_free(messages_locale);
+               } else {
+                       debug_print("couldn't set gpgme MESSAGES locale\n");
+               }
 #endif
                if (!gpgme_get_engine_info(&engineInfo)) {
                        while (engineInfo) {
 #endif
                if (!gpgme_get_engine_info(&engineInfo)) {
                        while (engineInfo) {
index 7ce5c1322b4b9d276f395ec0569d9eaf6386f4db..a5e2267677a0a2c3d032932a8f2b8c6641f203de 100644 (file)
@@ -730,6 +730,7 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
                gpgme_data_release(gpgtext);
                g_free(textstr);
                gpgme_release(ctx);
                gpgme_data_release(gpgtext);
                g_free(textstr);
                gpgme_release(ctx);
+               g_free(enccontent);
                return FALSE;
        }
 
                return FALSE;
        }
 
index d22a85af08f516fd1222119fb5f9e4aa2b0303c4..c97834d7ceca6d0194114dea8f95c24342457540 100644 (file)
@@ -581,6 +581,7 @@ gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account, const gchar *fr
                g_warning("sgpgme_data_release_and_get_mem failed");
                privacy_set_error(_("Data signing failed, no contents."));
                g_free(micalg);
                g_warning("sgpgme_data_release_and_get_mem failed");
                privacy_set_error(_("Data signing failed, no contents."));
                g_free(micalg);
+               g_free(sigcontent);
                return FALSE;
        }
 
                return FALSE;
        }
 
@@ -719,6 +720,7 @@ gboolean pgpmime_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
                g_warning("sgpgme_data_release_and_get_mem failed");
                privacy_set_error(_("Encryption failed, %s"), gpgme_strerror(err));
                gpgme_release(ctx);
                g_warning("sgpgme_data_release_and_get_mem failed");
                privacy_set_error(_("Encryption failed, %s"), gpgme_strerror(err));
                gpgme_release(ctx);
+               g_free(enccontent);
                return FALSE;
        }
 
                return FALSE;
        }
 
index fb4f98d0959a6d1978a448524fce304faad84cfa..36bff67e3401d98218832e3f7c8d1c470af07729 100644 (file)
@@ -352,12 +352,18 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
        if (mimeinfo->type == MIMETYPE_MULTIPART || mimeinfo->type == MIMETYPE_MESSAGE)
                return TRUE;
 
        if (mimeinfo->type == MIMETYPE_MULTIPART || mimeinfo->type == MIMETYPE_MESSAGE)
                return TRUE;
 
+       if (mimeinfo->data.filename == NULL)
+               return FALSE;
+
        infp = procmime_fopen(mimeinfo->data.filename, "rb");
        if (!infp) {
                perror("fopen");
                return FALSE;
        }
        infp = procmime_fopen(mimeinfo->data.filename, "rb");
        if (!infp) {
                perror("fopen");
                return FALSE;
        }
-       fseek(infp, mimeinfo->offset, SEEK_SET);
+       if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
+               perror("fseek");
+               return FALSE;
+       }
 
        outfp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
        if (!outfp) {
 
        outfp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmpfilename);
        if (!outfp) {
@@ -388,7 +394,7 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
                Base64Decoder *decoder;
                gboolean got_error = FALSE;
                gboolean uncanonicalize = FALSE;
                Base64Decoder *decoder;
                gboolean got_error = FALSE;
                gboolean uncanonicalize = FALSE;
-               FILE *tmpfp = outfp;
+               FILE *tmpfp = NULL;
                gboolean null_bytes = FALSE;
                gboolean starting = TRUE;
 
                gboolean null_bytes = FALSE;
                gboolean starting = TRUE;
 
@@ -406,7 +412,8 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
 #ifdef HAVE_FGETS_UNLOCKED
                        flockfile(tmpfp);
 #endif
 #ifdef HAVE_FGETS_UNLOCKED
                        flockfile(tmpfp);
 #endif
-               }
+               } else
+                       tmpfp = outfp;
 
                decoder = base64_decoder_new();
                while ((inlen = MIN(readend - ftell(infp), sizeof(buf))) > 0 && !err) {
 
                decoder = base64_decoder_new();
                while ((inlen = MIN(readend - ftell(infp), sizeof(buf))) > 0 && !err) {
@@ -493,8 +500,12 @@ gboolean procmime_decode_content(MimeInfo *mimeinfo)
                return FALSE;
        }
 
                return FALSE;
        }
 
-       g_stat(tmpfilename, &statbuf);
-       if (mimeinfo->tmp && (mimeinfo->data.filename != NULL))
+       if (g_stat(tmpfilename, &statbuf) < 0) {
+               FILE_OP_ERROR(tmpfilename, "stat");
+               return FALSE;
+       }
+
+       if (mimeinfo->tmp)
                claws_unlink(mimeinfo->data.filename);
        g_free(mimeinfo->data.filename);
        mimeinfo->data.filename = tmpfilename;
                claws_unlink(mimeinfo->data.filename);
        g_free(mimeinfo->data.filename);
        mimeinfo->data.filename = tmpfilename;
@@ -551,7 +562,10 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
 #ifdef HAVE_FGETS_UNLOCKED
                flockfile(infp);
 #endif
 #ifdef HAVE_FGETS_UNLOCKED
                flockfile(infp);
 #endif
-
+       } else {
+               procmime_fclose(outfp);
+               g_warning("Unknown mimeinfo");
+               return FALSE;
        }
 
        if (encoding == ENC_BASE64) {
        }
 
        if (encoding == ENC_BASE64) {
@@ -660,7 +674,10 @@ gboolean procmime_encode_content(MimeInfo *mimeinfo, EncodingType encoding)
                        g_free(mimeinfo->data.mem);
        }
 
                        g_free(mimeinfo->data.mem);
        }
 
-       g_stat(tmpfilename, &statbuf);
+       if (g_stat(tmpfilename, &statbuf) < 0) {
+               FILE_OP_ERROR(tmpfilename, "stat");
+               return FALSE;
+       }
        mimeinfo->content = MIMECONTENT_FILE;
        mimeinfo->data.filename = tmpfilename;
        mimeinfo->tmp = TRUE;
        mimeinfo->content = MIMECONTENT_FILE;
        mimeinfo->data.filename = tmpfilename;
        mimeinfo->tmp = TRUE;
@@ -1439,7 +1456,10 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_sca
                FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
                return;
        }
                FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
                return;
        }
-       fseek(fp, mimeinfo->offset, SEEK_SET);
+       if (fseek(fp, mimeinfo->offset, SEEK_SET) < 0) {
+               FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
+               return;
+       }
        procheader_get_header_fields(fp, hentry);
        if (hentry[0].body != NULL) {
                tmp = conv_unmime_header(hentry[0].body, NULL, FALSE);
        procheader_get_header_fields(fp, hentry);
        if (hentry[0].body != NULL) {
                tmp = conv_unmime_header(hentry[0].body, NULL, FALSE);
@@ -1616,7 +1636,7 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
                                {"Disposition:",
                                                   NULL, TRUE},
                                {NULL,             NULL, FALSE}};
                                {"Disposition:",
                                                   NULL, TRUE},
                                {NULL,             NULL, FALSE}};
-       gchar *p, *tmp;
+       gchar *tmp;
        gchar *boundary;
        gint boundary_len = 0, lastoffset = -1, i;
        gchar buf[BUFFSIZE];
        gchar *boundary;
        gint boundary_len = 0, lastoffset = -1, i;
        gchar buf[BUFFSIZE];
@@ -1638,8 +1658,12 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
                return;
        }
 
                return;
        }
 
-       fseek(fp, mimeinfo->offset, SEEK_SET);
-       while ((p = SC_FGETS(buf, sizeof(buf), fp)) != NULL && result == 0) {
+       if (fseek(fp, mimeinfo->offset, SEEK_SET) < 0) {
+               FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
+               return;
+       }
+
+       while (SC_FGETS(buf, sizeof(buf), fp) != NULL && result == 0) {
                if (ftell(fp) - 1 > (mimeinfo->offset + mimeinfo->length))
                        break;
 
                if (ftell(fp) - 1 > (mimeinfo->offset + mimeinfo->length))
                        break;
 
@@ -1726,7 +1750,7 @@ static void parse_parameters(const gchar *parameters, GHashTable *table)
 
                value[0] = '\0';
                value++;
 
                value[0] = '\0';
                value++;
-               while (value[0] == ' ')
+               while (value[0] != '\0' && value[0] == ' ')
                        value++;
 
                down_attr = g_utf8_strdown(attribute, -1);
                        value++;
 
                down_attr = g_utf8_strdown(attribute, -1);
@@ -1773,12 +1797,12 @@ static void parse_parameters(const gchar *parameters, GHashTable *table)
                        while (down_attr[strlen(down_attr)-1] == ' ') 
                                down_attr[strlen(down_attr)-1] = '\0';
                } 
                        while (down_attr[strlen(down_attr)-1] == ' ') 
                                down_attr[strlen(down_attr)-1] = '\0';
                } 
-               if (value) {
-                       while (value[0] == ' ')
-                               value++;
-                       while (value[strlen(value)-1] == ' ') 
-                               value[strlen(value)-1] = '\0';
-               }               
+
+               while (value[0] != '\0' && value[0] == ' ')
+                       value++;
+               while (value[strlen(value)-1] == ' ') 
+                       value[strlen(value)-1] = '\0';
+
                if (down_attr && strrchr(down_attr, '*') != NULL) {
                        gchar *tmpattr;
 
                if (down_attr && strrchr(down_attr, '*') != NULL) {
                        gchar *tmpattr;
 
@@ -2133,7 +2157,10 @@ static MimeInfo *procmime_scan_file_with_offset(const gchar *filename, int offse
        MimeInfo *mimeinfo;
        struct stat buf;
 
        MimeInfo *mimeinfo;
        struct stat buf;
 
-       g_stat(filename, &buf);
+       if (g_stat(filename, &buf) < 0) {
+               FILE_OP_ERROR(filename, "stat");
+               return NULL;
+       }
 
        mimeinfo = procmime_mimeinfo_new();
        mimeinfo->content = MIMECONTENT_FILE;
 
        mimeinfo = procmime_mimeinfo_new();
        mimeinfo->content = MIMECONTENT_FILE;
@@ -2459,7 +2486,10 @@ static gint procmime_write_message_rfc822(MimeInfo *mimeinfo, FILE *fp)
                        FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
                        return -1;
                }
                        FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
                        return -1;
                }
-               fseek(infp, mimeinfo->offset, SEEK_SET);
+               if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
+                       FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
+                       return -1;
+               }
                while (SC_FGETS(buf, sizeof(buf), infp) == buf) {
                        strcrchomp(buf);
                        if (buf[0] == '\n' && buf[1] == '\0')
                while (SC_FGETS(buf, sizeof(buf), infp) == buf) {
                        strcrchomp(buf);
                        if (buf[0] == '\n' && buf[1] == '\0')
@@ -2532,7 +2562,10 @@ static gint procmime_write_multipart(MimeInfo *mimeinfo, FILE *fp)
                        FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
                        return -1;
                }
                        FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
                        return -1;
                }
-               fseek(infp, mimeinfo->offset, SEEK_SET);
+               if (fseek(infp, mimeinfo->offset, SEEK_SET) < 0) {
+                       FILE_OP_ERROR(mimeinfo->data.filename, "fseek");
+                       return -1;
+               }
                while (SC_FGETS(buf, sizeof(buf), infp) == buf) {
                        if (IS_BOUNDARY(buf, boundary, strlen(boundary)))
                                break;
                while (SC_FGETS(buf, sizeof(buf), infp) == buf) {
                        if (IS_BOUNDARY(buf, boundary, strlen(boundary)))
                                break;
index cc10712c9963210b6949dc41c7c08be67feef222..5bf6513dbbc5d27e04bf7d53791d179550f6cd4f 100644 (file)
@@ -890,7 +890,7 @@ parse_again:
                cur = cur->next;
        }
        
                cur = cur->next;
        }
        
-       if (orig || g_slist_length(orig)) {
+       if (orig && g_slist_length(orig)) {
                if (!last_account && nothing_to_sort) {
                        /* can't find an account for the rest of the list */
                        cur = orig;
                if (!last_account && nothing_to_sort) {
                        /* can't find an account for the rest of the list */
                        cur = orig;
@@ -1123,8 +1123,14 @@ gint procmsg_remove_special_headers(const gchar *in, const gchar *out)
                        break;
                }
        }
                        break;
                }
        }
-       while (fgets(buf, sizeof(buf), fp) != NULL)
-               fputs(buf, outfp);
+       while (fgets(buf, sizeof(buf), fp) != NULL) {
+               if (fputs(buf, outfp) == EOF) {
+                       FILE_OP_ERROR(out, "fputs");
+                       fclose(outfp);
+                       fclose(fp);
+                       return -1;
+               }
+       }
        fclose(outfp);
        fclose(fp);
        return 0;
        fclose(outfp);
        fclose(fp);
        return 0;
@@ -1185,80 +1191,6 @@ static gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
 }
 
 
 }
 
 
-void procmsg_print_message(MsgInfo *msginfo, const gchar *cmdline)
-{
-       static const gchar *def_cmd = "lpr %s";
-       static guint id = 0;
-       gchar *prtmp;
-       FILE *tmpfp, *prfp;
-       gchar buf[1024];
-       gchar *p;
-       int r;
-
-       cm_return_if_fail(msginfo);
-
-       if (procmime_msginfo_is_encrypted(msginfo))
-               tmpfp = procmime_get_first_encrypted_text_content(msginfo);
-       else
-               tmpfp = procmime_get_first_text_content(msginfo);
-       if (tmpfp == NULL) {
-               g_warning("Can't get text part\n");
-               return;
-       }
-
-       prtmp = g_strdup_printf("%s%cprinttmp.%08x",
-                               get_mime_tmp_dir(), G_DIR_SEPARATOR, id++);
-
-       if ((prfp = g_fopen(prtmp, "wb")) == NULL) {
-               FILE_OP_ERROR(prtmp, "fopen");
-               g_free(prtmp);
-               fclose(tmpfp);
-               return;
-       }
-
-       if (msginfo->date) { r = fprintf(prfp, "Date: %s\n", msginfo->date); if (r < 0) goto fpferr; }
-       if (msginfo->from) { r = fprintf(prfp, "From: %s\n", msginfo->from); if (r < 0) goto fpferr; }
-       if (msginfo->to)   { r = fprintf(prfp, "To: %s\n", msginfo->to); if (r < 0) goto fpferr; }
-       if (msginfo->cc)   { r = fprintf(prfp, "Cc: %s\n", msginfo->cc); if (r < 0) goto fpferr; }
-       if (msginfo->newsgroups) {
-               r = fprintf(prfp, "Newsgroups: %s\n", msginfo->newsgroups); if (r < 0) goto fpferr;
-       }
-       if (msginfo->subject) { r = fprintf(prfp, "Subject: %s\n", msginfo->subject); if (r < 0) goto fpferr; }
-       if (fputc('\n', prfp) == EOF) goto fpferr;
-
-       while (fgets(buf, sizeof(buf), tmpfp) != NULL) {
-               r = fputs(buf, prfp);
-               if (r == EOF) goto fpferr;
-       }
-
-       fclose(prfp);
-       fclose(tmpfp);
-
-       if (cmdline && (p = strchr(cmdline, '%')) && *(p + 1) == 's' &&
-           !strchr(p + 2, '%'))
-               g_snprintf(buf, sizeof(buf) - 1, cmdline, prtmp);
-       else {
-               if (cmdline)
-                       g_warning("Print command-line is invalid: '%s'\n",
-                                 cmdline);
-               g_snprintf(buf, sizeof(buf) - 1, def_cmd, prtmp);
-       }
-
-       g_free(prtmp);
-
-       g_strchomp(buf);
-       if (buf[strlen(buf) - 1] != '&')
-               strncat(buf, "&", sizeof(buf) - strlen(buf) - 1);
-       if (system(buf) == -1)
-               g_warning("system(%s) failed.", buf);
-       return;
-fpferr:
-       FILE_OP_ERROR(prtmp, "fprintf/fputc/fputs");
-       g_free(prtmp);
-       fclose(tmpfp);
-       fclose(prfp);
-}
-
 MsgInfo *procmsg_msginfo_new_ref(MsgInfo *msginfo)
 {
        msginfo->refcnt++;
 MsgInfo *procmsg_msginfo_new_ref(MsgInfo *msginfo)
 {
        msginfo->refcnt++;
@@ -1690,6 +1622,14 @@ static gint procmsg_send_message_queue_full(const gchar *file, gboolean keep_ses
        }
 send_mail:
        filepos = ftell(fp);
        }
 send_mail:
        filepos = ftell(fp);
+       if (filepos < 0) {
+               FILE_OP_ERROR(file, "ftell");
+               if (errstr) {
+                       if (*errstr) g_free(*errstr);
+                       *errstr = g_strdup_printf(_("Couldn't open file %s."), file);
+               }
+               return -1;
+       }
 
        if (encrypt) {
                MimeInfo *mimeinfo;
 
        if (encrypt) {
                MimeInfo *mimeinfo;
@@ -1802,7 +1742,11 @@ send_mail:
                mailval = -1;
        }
 
                mailval = -1;
        }
 
-       fseek(fp, filepos, SEEK_SET);
+       if (fseek(fp, filepos, SEEK_SET) < 0) {
+               FILE_OP_ERROR(file, "fseek");
+               mailval = -1;
+       }
+
        if (newsgroup_list && newsac && (mailval == 0)) {
                Folder *folder;
                gchar *tmp = NULL;
        if (newsgroup_list && newsac && (mailval == 0)) {
                Folder *folder;
                gchar *tmp = NULL;
index 9bccc2be33efd5403d96c68a41b2eac13f9a7598..b7fb87033bee9e20ed2ecc27865cf987ace9bbf2 100644 (file)
@@ -334,8 +334,6 @@ gint        procmsg_send_queue              (FolderItem     *queue,
 gboolean procmsg_queue_lock            (gchar          **errstr);
 void     procmsg_queue_unlock          (void);
 gboolean procmsg_queue_is_empty        (FolderItem *queue);
 gboolean procmsg_queue_lock            (gchar          **errstr);
 void     procmsg_queue_unlock          (void);
 gboolean procmsg_queue_is_empty        (FolderItem *queue);
-void   procmsg_print_message           (MsgInfo        *msginfo,
-                                        const gchar    *cmdline);
 
 MsgInfo *procmsg_msginfo_new           ();
 MsgInfo *procmsg_msginfo_new_ref       (MsgInfo        *msginfo);
 
 MsgInfo *procmsg_msginfo_new           ();
 MsgInfo *procmsg_msginfo_new_ref       (MsgInfo        *msginfo);
index 102961df95e273c89bfdcf619276cec598bf064e..ae63375a2d69546f036fe9041b4748eefcac224a 100644 (file)
@@ -6185,7 +6185,7 @@ static gint summary_tag_cmp_list(gconstpointer a, gconstpointer b)
                return tag_b == NULL ? 0:1;
        
        if (tag_b == NULL)
                return tag_b == NULL ? 0:1;
        
        if (tag_b == NULL)
-               return tag_a == NULL ? 0:1;
+               return 1;
 
        return g_utf8_collate(tag_a, tag_b);
 }
 
        return g_utf8_collate(tag_a, tag_b);
 }
index 9131f91f29b06fc52d46cac98b772c41df48f077..31708d69f1245469950ec06a72e9ec1629d8c366 100644 (file)
@@ -2146,7 +2146,7 @@ static gint textview_tag_cmp_list(gconstpointer a, gconstpointer b)
                return tag_b == NULL ? 0:1;
        
        if (tag_b == NULL)
                return tag_b == NULL ? 0:1;
        
        if (tag_b == NULL)
-               return tag_a == NULL ? 0:1;
+               return 1;
 
        return g_utf8_collate(tag_a, tag_b);
 }
 
        return g_utf8_collate(tag_a, tag_b);
 }