Normalize rfc822 date handling by using decent buffer sizes everywhere (128,
authorwwp <wwp@free.fr>
Fri, 20 Jan 2017 09:48:08 +0000 (10:48 +0100)
committerwwp <wwp@free.fr>
Fri, 20 Jan 2017 09:48:08 +0000 (10:48 +0100)
which is way more than what RFC822 says: 37 max) and specific buffers.

src/common/defs.h
src/common/utils.c
src/compose.c
src/messageview.c
src/news.c
src/plugins/fetchinfo/fetchinfo_plugin.c
src/plugins/vcalendar/vcal_manager.c
src/wizard.c

index c10ac659d309dd8a78a956b0c9688c9638d66783..4c4fd39eb704815da5cbec92c7b6860edd1dc6f4 100644 (file)
 
 #define BUFFSIZE                       8192
 
+#define RFC822_DATE_BUFFSIZE   128
+
 #ifndef MAXPATHLEN
 #  define MAXPATHLEN                   4095
 #endif
index b13d09a67752c08d9049cedaa5b5f22e00194531..cb4822151468678bcbd499d7b0f0991bcbe71520 100644 (file)
@@ -3533,7 +3533,7 @@ static void _get_rfc822_date(gchar *buf, gint len, gboolean hidetz)
        gchar day[4], mon[4];
        gint dd, hh, mm, ss, yyyy;
        struct tm buf1;
-       gchar buf2[BUFFSIZE];
+       gchar buf2[RFC822_DATE_BUFFSIZE];
 
        t = time(NULL);
        lt = localtime_r(&t, &buf1);
index 07bdeafb54ee06581960f83dd60ebd398f4020ec..21dae0c4e67022d671cb3e07487e7f6d89c90b79 100644 (file)
@@ -5445,6 +5445,7 @@ static gint compose_redirect_write_headers_from_headerlist(Compose *compose,
 
 static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
 {
+       gchar date[RFC822_DATE_BUFFSIZE];
        gchar buf[BUFFSIZE];
        gchar *str;
        const gchar *entstr;
@@ -5457,9 +5458,9 @@ static gint compose_redirect_write_headers(Compose *compose, FILE *fp)
 
        /* Resent-Date */
        if (prefs_common.hide_timezone)
-               get_rfc822_date_hide_tz(buf, sizeof(buf));
+               get_rfc822_date_hide_tz(date, sizeof(date));
        else
-               get_rfc822_date(buf, sizeof(buf));
+               get_rfc822_date(date, sizeof(date));
        err |= (fprintf(fp, "Resent-Date: %s\n", buf) < 0);
 
        /* Resent-From */
@@ -6566,6 +6567,7 @@ static gchar *compose_get_manual_headers_info(Compose *compose)
 
 static gchar *compose_get_header(Compose *compose)
 {
+       gchar date[RFC822_DATE_BUFFSIZE];
        gchar buf[BUFFSIZE];
        const gchar *entry_str;
        gchar *str;
@@ -6583,10 +6585,10 @@ static gchar *compose_get_header(Compose *compose)
 
        /* Date */
        if (prefs_common.hide_timezone)
-               get_rfc822_date_hide_tz(buf, sizeof(buf));
+               get_rfc822_date_hide_tz(date, sizeof(date));
        else
-               get_rfc822_date(buf, sizeof(buf));
-       g_string_append_printf(header, "Date: %s\n", buf);
+               get_rfc822_date(date, sizeof(date));
+       g_string_append_printf(header, "Date: %s\n", date);
 
        /* From */
        
@@ -12136,15 +12138,15 @@ static MsgInfo *compose_msginfo_new_from_compose(Compose *compose)
 {
        MsgInfo *newmsginfo;
        GSList *list;
-       gchar buf[BUFFSIZE];
+       gchar date[RFC822_DATE_BUFFSIZE];
 
        cm_return_val_if_fail( compose != NULL, NULL );
 
        newmsginfo = procmsg_msginfo_new();
 
        /* date is now */
-       get_rfc822_date(buf, sizeof(buf));
-       newmsginfo->date = g_strdup(buf);
+       get_rfc822_date(date, sizeof(date));
+       newmsginfo->date = g_strdup(date);
 
        /* from */
        if (compose->from_name) {
index 4e15e0710360d999ce0028af31c66a7e79e4bcf8..8ff089e93f49b912d6996c799444e1b6435edf47 100644 (file)
@@ -817,7 +817,7 @@ static gint disposition_notification_send(MsgInfo *msginfo)
        gchar *foo = NULL;
        gboolean queued_removed = FALSE;
        gchar *boundary = NULL;
-       gchar buf_date[BUFFSIZE];
+       gchar buf_date[RFC822_DATE_BUFFSIZE];
        gchar *date = NULL;
        gchar *orig_to = NULL;
        gchar *enc_sub = NULL;
index d510da93b1425a0d80cbdf21893c0e667d783f07..720b0694d7b5413afe36a7fa02f7d5dda8dee3f2 100644 (file)
@@ -920,7 +920,7 @@ static MsgInfo *news_parse_xover(struct newsnntp_xover_resp_item *item)
                                 msginfo->inreplyto = g_strdup(p);
                 }
                g_free(tmp);
-        
+       } 
 
        return msginfo;
 }
@@ -929,7 +929,7 @@ gint news_cancel_article(Folder * folder, MsgInfo * msginfo)
 {
        gchar * tmp;
        FILE * tmpfp;
-       gchar buf[BUFFSIZE];
+       gchar date[RFC822_DATE_BUFFSIZE];
 
        tmp = g_strdup_printf("%s%ccancel%p", get_tmp_dir(),
                              G_DIR_SEPARATOR, msginfo);
@@ -946,9 +946,9 @@ gint news_cancel_article(Folder * folder, MsgInfo * msginfo)
        }
        
        if (prefs_common.hide_timezone)
-               get_rfc822_date_hide_tz(buf, sizeof(buf));
+               get_rfc822_date_hide_tz(date, sizeof(date));
        else
-               get_rfc822_date(buf, sizeof(buf));
+               get_rfc822_date(date, sizeof(date));
        if (fprintf(tmpfp, "From: %s\r\n"
                       "Newsgroups: %s\r\n"
                       "Subject: cmsg cancel <%s>\r\n"
@@ -964,7 +964,7 @@ gint news_cancel_article(Folder * folder, MsgInfo * msginfo)
                       msginfo->msgid,
                       msginfo->from,
                       msginfo->from,
-                      buf) < 0) {
+                      date) < 0) {
                FILE_OP_ERROR(tmp, "fprintf");
                fclose(tmpfp);
                claws_unlink(tmp);
index d5e374e5872ca110e7361930b0d5486e0421abc8..04faeadc678de2b9dbb8e11ebb988b6c2a5ddd2f 100644 (file)
@@ -49,18 +49,12 @@ static guint mail_receive_hook_id;
 static FetchinfoConfig config;
 
 static PrefParam param[] = {
-       {"fetchinfo_enable",    "FALSE", &config.fetchinfo_enable,              
-                               P_BOOL, NULL, NULL, NULL},
-       {"fetchinfo_uidl",      "TRUE", &config.fetchinfo_uidl,         
-                               P_BOOL, NULL, NULL, NULL},
-       {"fetchinfo_account",   "TRUE", &config.fetchinfo_account,
-                               P_BOOL, NULL, NULL, NULL},
-       {"fetchinfo_server",    "TRUE", &config.fetchinfo_server,
-                               P_BOOL, NULL, NULL, NULL},
-       {"fetchinfo_userid",    "TRUE", &config.fetchinfo_userid,
-                               P_BOOL, NULL, NULL, NULL},
-       {"fetchinfo_time",      "TRUE", &config.fetchinfo_time,
-                               P_BOOL, NULL, NULL, NULL},
+       {"fetchinfo_enable",  "FALSE", &config.fetchinfo_enable, P_BOOL, NULL, NULL, NULL},
+       {"fetchinfo_uidl",    "TRUE", &config.fetchinfo_uidl, P_BOOL, NULL, NULL, NULL},
+       {"fetchinfo_account", "TRUE", &config.fetchinfo_account, P_BOOL, NULL, NULL, NULL},
+       {"fetchinfo_server",  "TRUE", &config.fetchinfo_server, P_BOOL, NULL, NULL, NULL},
+       {"fetchinfo_userid",  "TRUE", &config.fetchinfo_userid, P_BOOL, NULL, NULL, NULL},
+       {"fetchinfo_time",    "TRUE", &config.fetchinfo_time, P_BOOL, NULL, NULL, NULL},
 
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
 };
@@ -88,7 +82,7 @@ static gboolean mail_receive_hook(gpointer source, gpointer data)
        Pop3Session *session;
        gchar *newheaders;
        gchar *newdata;
-       gchar date[PREFSBUFSIZE];
+       gchar date[RFC822_DATE_BUFFSIZE];
        
        if (!config.fetchinfo_enable) {
                return FALSE;
@@ -101,7 +95,7 @@ static gboolean mail_receive_hook(gpointer source, gpointer data)
                              FALSE );
 
        session = mail_receive_data->session;
-       get_rfc822_date(date, PREFSBUFSIZE);
+       get_rfc822_date(date, sizeof(date));
        newheaders = g_strdup("");
 
        if (config.fetchinfo_uidl)
index 6732fd5afac147d091ae9a8795198a4d59c8d992..964beec1f34e2768482d0d5a90c5fa4ccecaec49 100644 (file)
@@ -50,6 +50,7 @@
 #include "folder.h"
 #include "quoted-printable.h"
 #include "utils.h"
+#include "defs.h"
 
 #ifdef G_OS_WIN32
 #define getuid() 0
@@ -544,7 +545,7 @@ static gchar *write_headers_date(const gchar *uid)
 {
        gchar subject[512];
        gchar *t_subject;
-       gchar date[128];
+       gchar date[RFC822_DATE_BUFFSIZE];
        time_t t;
        struct tm lt;
 
@@ -1182,7 +1183,7 @@ static gchar *write_headers(PrefsAccount  *account,
                            gboolean             is_pseudo_display)
 {
        gchar *subject = NULL;
-       gchar date[128];
+       gchar date[RFC822_DATE_BUFFSIZE];
        gchar *save_folder = NULL;
        gchar *result = NULL;
        gchar *queue_headers = NULL;
@@ -1323,7 +1324,7 @@ static gchar *write_headers_ical(PrefsAccount     *account,
                            gchar               *orga)
 {
        gchar subject[512];
-       gchar date[128];
+       gchar date[RFC822_DATE_BUFFSIZE];
        gchar *result = NULL;
        gchar *method_str = NULL;
        gchar *summary = NULL;
index 1fac967c110fae8f23bff1f9a03fe8c3874672eb..d16a8b460481eea99dd8477dd444a40bfdf42398 100644 (file)
@@ -505,7 +505,7 @@ static void initialize_fonts(WizardWindow *wizard)
 
 static void write_welcome_email(WizardWindow *wizard)
 {
-       gchar buf_date[64];
+       gchar date[RFC822_DATE_BUFFSIZE];
        gchar *head=NULL;
        gchar *body=NULL;
        gchar *msg=NULL;
@@ -515,7 +515,7 @@ static void write_welcome_email(WizardWindow *wizard)
        gchar *file = get_tmp_file();
        gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
        
-       get_rfc822_date(buf_date, sizeof(buf_date));
+       get_rfc822_date(date, sizeof(date));
 
        conv_encode_header_full(enc_subject, sizeof(enc_subject), 
                        C_("Welcome Mail Subject", "Welcome to Claws Mail"),
@@ -539,7 +539,7 @@ static void write_welcome_email(WizardWindow *wizard)
                USERS_ML_ADDR,
                enc_to_name,
                gtk_entry_get_text(GTK_ENTRY(wizard->email)),
-               buf_date, enc_subject, XFACE, FACE);
+               date, enc_subject, XFACE, FACE);
        body = g_strdup_printf(
                _("\n"
                "Welcome to Claws Mail\n"