From 91c78f7672c2d4c186ec35e8c34481d565dfc25d Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Fri, 29 Mar 2013 20:13:34 +0100 Subject: [PATCH 1/6] Regenerate the Date header after signing Previously the difference to the signature timestamp could be used to estimate the passphrase length for the signing key (if the passphrase wasn't cached). --- src/compose.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/compose.c b/src/compose.c index e1323f2..3d55963 100644 --- a/src/compose.c +++ b/src/compose.c @@ -5709,12 +5709,31 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action, gbool } /* sign message if sending */ if (action == COMPOSE_WRITE_FOR_SEND && compose->use_signing && - privacy_system_can_sign(compose->privacy_system)) - if (!privacy_sign(compose->privacy_system, mimemsg, - compose->account, from_addr)) { + privacy_system_can_sign(compose->privacy_system)) { + gchar *date; + gchar *end; + gboolean message_signed; + gboolean date_found; + + date = mimemsg->data.mem + strlen("Date: "); + end = strchr(date, '\n'); + + message_signed = privacy_sign(compose->privacy_system, mimemsg, + compose->account, from_addr); + date_found = !strncmp(mimemsg->data.mem, "Date: ", strlen("Date: ")); + + if (!message_signed || !date_found || end == NULL) { g_free(from_name); g_free(from_addr); return -2; + } + /* + * Regenerate the Date header so the difference to the + * signature timestamp can't be used to estimate the + * passphrase length for the signing key. + */ + get_rfc822_date(date, strlen(date)); + *end = '\n'; } g_free(from_name); g_free(from_addr); -- 1.9.0 From a4ecf5b15a9fe6acc6c6dbce50d7aa2c8002f443 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Mon, 13 May 2013 15:43:08 +0200 Subject: [PATCH 2/6] Fix segfault in nntp_disconnect_all() due to pointer truncation --- src/news.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/news.c b/src/news.c index d678e8f..85f4572 100644 --- a/src/news.c +++ b/src/news.c @@ -36,6 +36,7 @@ #include #include +#include "account.h" #include "nntp-thread.h" #include "news.h" #include "news_gtk.h" -- 1.9.0 From bf6e247a47cc7ba26f3e75085f957c70ef753601 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 10 Oct 2012 20:14:37 +0200 Subject: [PATCH 3/6] In case of multiple matching encryption keys, use the most recent one without bothering the user --- src/plugins/pgpcore/select-keys.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/plugins/pgpcore/select-keys.c b/src/plugins/pgpcore/select-keys.c index 6559220..8e4a110 100644 --- a/src/plugins/pgpcore/select-keys.c +++ b/src/plugins/pgpcore/select-keys.c @@ -274,6 +274,7 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot cm_return_val_if_fail (sk, NULL); clist = sk->clist; cm_return_val_if_fail (clist, NULL); + static int use_most_recent_key = 1; debug_print ("select_keys:fill_clist: pattern '%s' proto %d\n", pattern, proto); @@ -302,7 +303,6 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot if (!key->can_encrypt || key->revoked || key->expired || key->disabled) continue; debug_print ("%% %s:%d: insert\n", __FILE__ ,__LINE__ ); - set_row (clist, key, proto ); for (; uid; uid = uid->next) { gchar *raw_mail = NULL; @@ -320,14 +320,37 @@ fill_clist (struct select_keys_s *sk, const char *pattern, gpgme_protocol_t prot } g_free(raw_mail); } - num_results++; - last_key = key; + if (use_most_recent_key) { + if (last_key == NULL) { + debug_print ("%s:%d: First matching key for %s has fingerprint %s\n", + __FILE__ ,__LINE__, pattern, key->subkeys->fpr); + last_key = key; + } else if (key->subkeys->timestamp > last_key->subkeys->timestamp) { + debug_print ("%s:%d: Ditching key %s in favor of the more recent %s\n", + __FILE__ ,__LINE__, last_key->subkeys->fpr, key->subkeys->fpr); + last_key = key; + } else { + debug_print ("%s:%d: Not chosing key %s as it's older than the current choice\n", + __FILE__ ,__LINE__, key->subkeys->fpr); + } + } else { + set_row (clist, key, proto ); + num_results++; + last_key = key; + } key = NULL; update_progress (sk, ++running, pattern); while (gtk_events_pending ()) gtk_main_iteration (); } - + + if (use_most_recent_key && last_key) { + debug_print ("%s:%d: The final key for %s has fingerprint %s\n", + __FILE__ ,__LINE__, pattern, last_key->subkeys->fpr); + set_row (clist, last_key, proto ); + num_results++; + } + if (exact_match == TRUE && num_results == 1) { if (last_key->uids->validity < GPGME_VALIDITY_FULL && !use_untrusted(last_key, last_uid, proto)) -- 1.9.0 From 371d37523da385f21a7dcb4ca8de5df879bd5b41 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Fri, 8 Feb 2013 09:19:30 +0100 Subject: [PATCH 4/6] Slightly simplify pgpinline_is_signed() by using gpinline_locate_armor_header() --- src/plugins/pgpinline/pgpinline.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/plugins/pgpinline/pgpinline.c b/src/plugins/pgpinline/pgpinline.c index a5e2267..936537a 100644 --- a/src/plugins/pgpinline/pgpinline.c +++ b/src/plugins/pgpinline/pgpinline.c @@ -120,13 +120,9 @@ static gboolean pgpinline_is_signed(MimeInfo *mimeinfo) textdata = get_part_as_string(mimeinfo); if (!textdata) return FALSE; - - if ((sigpos = strstr(textdata, sig_indicator)) == NULL) { - g_free(textdata); - return FALSE; - } - if (!(sigpos == textdata) && !(sigpos[-1] == '\n')) { + sigpos = pgpinline_locate_armor_header(textdata, sig_indicator); + if (sigpos == NULL) { g_free(textdata); return FALSE; } -- 1.9.0 From 7446da29f34a556df8c4d5d2b28af1ed204065fc Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Wed, 4 Sep 2013 21:29:56 +0200 Subject: [PATCH 5/6] Don't advertise the local time through the Message-ID --- src/common/utils.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/common/utils.c b/src/common/utils.c index cca8c18..ce9c06c 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -3881,13 +3881,7 @@ gint g_int_compare(gconstpointer a, gconstpointer b) gchar *generate_msgid(gchar *buf, gint len, gchar *user_addr) { - struct tm *lt; - time_t t; gchar *addr; - struct tm buft; - - t = time(NULL); - lt = localtime_r(&t, &buft); if (user_addr != NULL) addr = g_strdup_printf(".%s", user_addr); @@ -3902,10 +3896,7 @@ gchar *generate_msgid(gchar *buf, gint len, gchar *user_addr) while (strchr(addr, '@') != NULL && strchr(addr, '@') != strrchr(addr, '@')) *(strchr(addr, '@')) = '_'; - g_snprintf(buf, len, "%04d%02d%02d%02d%02d%02d.%08x%s", - lt->tm_year + 1900, lt->tm_mon + 1, - lt->tm_mday, lt->tm_hour, - lt->tm_min, lt->tm_sec, + g_snprintf(buf, len, "%08x.%08x%s", (guint) rand(), (guint) rand(), addr); g_free(addr); -- 1.9.0 From d4fcc2ec1ec36a915e4d00af1ac7c521f4e3e3b1 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 29 Jul 2014 19:50:40 +0200 Subject: [PATCH 6/6] Let sc_html_parse_tag() properly deal with
--- src/html.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/html.c b/src/html.c index 71338af..ff5a61e 100644 --- a/src/html.c +++ b/src/html.c @@ -643,7 +643,7 @@ static SC_HTMLState sc_html_parse_tag(SC_HTMLParser *parser) parser->state = SC_HTML_UNKNOWN; if (!tag) return SC_HTML_UNKNOWN; - if (!strcmp(tag->name, "br")) { + if (!strcmp(tag->name, "br") || !strcmp(tag->name, "br/")) { parser->space = FALSE; sc_html_append_char(parser, '\n'); parser->state = SC_HTML_BR; -- 1.9.0