2005-10-19 [colin] 1.9.15cvs76
authorColin Leroy <colin@colino.net>
Wed, 19 Oct 2005 19:46:57 +0000 (19:46 +0000)
committerColin Leroy <colin@colino.net>
Wed, 19 Oct 2005 19:46:57 +0000 (19:46 +0000)
* src/common/utils.c
Use shorter mime boundaries to avoid having
MTAs rewrapping our headers, breaking the
PGP signature in the process
* src/compose.c
* src/plugins/pgpmime/pgpmime.c
Check for boundary uniqueness to be sure
it won't happen, instead of hoping for the
best

ChangeLog-gtk2.claws
PATCHSETS
configure.ac
src/common/utils.c
src/compose.c
src/plugins/pgpmime/pgpmime.c

index f0fb4ed..04934ac 100644 (file)
@@ -1,3 +1,15 @@
+2005-10-19 [colin]     1.9.15cvs76
+
+       * src/common/utils.c
+               Use shorter mime boundaries to avoid having
+               MTAs rewrapping our headers, breaking the
+               PGP signature in the process 
+       * src/compose.c
+       * src/plugins/pgpmime/pgpmime.c
+               Check for boundary uniqueness to be sure
+               it won't happen, instead of hoping for the
+               best
+
 2005-10-19 [colin]     1.9.15cvs75
 
        * sylpheed-claws.desktop
index 452f967..9a097cb 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/plugins/pgpcore/passphrase.c;  ) > 1.9.15cvs73.patchset
 ( cvs diff -u -r 1.213.2.64 -r 1.213.2.65 src/folder.c;  cvs diff -u -r 1.207.2.74 -r 1.207.2.75 src/folderview.c;  ) > 1.9.15cvs74.patchset
 ( cvs diff -u -r 1.1.2.2 -r 1.1.2.3 sylpheed-claws.desktop;  cvs diff -u -r 1.155.2.33 -r 1.155.2.34 src/Makefile.am;  cvs diff -u -r 1.207.2.75 -r 1.207.2.76 src/folderview.c;  cvs diff -u -r 1.115.2.60 -r 1.115.2.61 src/main.c;  cvs diff -u -r 1.1.2.21 -r 1.1.2.22 src/wizard.c;  ) > 1.9.15cvs75.patchset
+( cvs diff -u -r 1.382.2.184 -r 1.382.2.185 src/compose.c;  cvs diff -u -r 1.36.2.45 -r 1.36.2.46 src/common/utils.c;  cvs diff -u -r 1.1.2.25 -r 1.1.2.26 src/plugins/pgpmime/pgpmime.c;  ) > 1.9.15cvs76.patchset
index 4928e14..76af208 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=15
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=75
+EXTRA_VERSION=76
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 54d4323..baf5873 100644 (file)
@@ -3035,8 +3035,7 @@ gchar *get_outgoing_rfc2822_str(FILE *fp)
  * uniqueness if everything is either quoted-printable or base64
  * encoded (note that conversion is allowed), but because MIME bodies
  * may be nested, it may happen that the same boundary has already
- * been used. We avoid scanning the message for conflicts and hope the
- * best.
+ * been used. 
  *
  *   boundary := 0*69<bchars> bcharsnospace
  *   bchars := bcharsnospace / " "
@@ -3052,21 +3051,15 @@ gchar *generate_mime_boundary(const gchar *prefix)
        static gchar tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                             "abcdefghijklmnopqrstuvwxyz"
                             "1234567890+_./=";
-       gchar buf_uniq[17];
-       gchar buf_date[64];
+       gchar buf_uniq[24];
        gint i;
 
        for (i = 0; i < sizeof(buf_uniq) - 1; i++)
                buf_uniq[i] = tbl[g_random_int_range(0, sizeof(tbl) - 1)];
        buf_uniq[i] = '\0';
 
-       get_rfc822_date(buf_date, sizeof(buf_date));
-       subst_char(buf_date, ' ', '_');
-       subst_char(buf_date, ',', '_');
-       subst_char(buf_date, ':', '_');
-
-       return g_strdup_printf("%s_%s_%s", prefix ? prefix : "Multipart",
-                              buf_date, buf_uniq);
+       return g_strdup_printf("%s_%s", prefix ? prefix : "MP",
+                              buf_uniq);
 }
 
 gint change_file_mode_rw(FILE *fp, const gchar *file)
index 27bc06e..3aad20a 100644 (file)
@@ -4028,13 +4028,20 @@ static gint compose_write_to_file(Compose *compose, FILE *fp, gint action)
        /* append attachment parts */
        if (compose_use_attach(compose)) {
                MimeInfo *mimempart;
-
+               gchar *boundary = NULL;
                mimempart = procmime_mimeinfo_new();
                mimempart->content = MIMECONTENT_EMPTY;
                mimempart->type = MIMETYPE_MULTIPART;
                mimempart->subtype = g_strdup("mixed");
+
+               do {
+                       if (boundary)
+                               g_free(boundary);
+                       boundary = generate_mime_boundary(NULL);
+               } while (strstr(buf, boundary) != NULL);
+
                g_hash_table_insert(mimempart->typeparameters, g_strdup("boundary"),
-                                   generate_mime_boundary(NULL));
+                                   boundary);
 
                mimetext->disposition = DISPOSITIONTYPE_INLINE;
 
index 8241c8b..801a717 100644 (file)
@@ -394,13 +394,23 @@ gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
        MimeInfo *msgcontent, *sigmultipart, *newinfo;
        gchar *textstr, *micalg;
        FILE *fp;
-       gchar *boundary, *sigcontent;
+       gchar *boundary = NULL;
+       gchar *sigcontent;
        gpgme_ctx_t ctx;
        gpgme_data_t gpgtext, gpgsig;
        size_t len;
        struct passphrase_cb_info_s info;
        gpgme_sign_result_t result = NULL;
+       gchar *test_msg;
+       
+       fp = my_tmpfile();
+       procmime_write_mimeinfo(mimeinfo, fp);
+       rewind(fp);
 
+       /* read temporary file into memory */
+       test_msg = file_read_stream_to_str(fp);
+       fclose(fp);
+       
        memset (&info, 0, sizeof info);
 
        /* remove content node from message */
@@ -411,7 +421,15 @@ gboolean pgpmime_sign(MimeInfo *mimeinfo, PrefsAccount *account)
        sigmultipart = procmime_mimeinfo_new();
        sigmultipart->type = MIMETYPE_MULTIPART;
        sigmultipart->subtype = g_strdup("signed");
-       boundary = generate_mime_boundary("Signature");
+       
+       do {
+               if (boundary)
+                       g_free(boundary);
+               boundary = generate_mime_boundary("Sig");
+       } while (strstr(test_msg, boundary) != NULL);
+       
+       g_free(test_msg);
+
        g_hash_table_insert(sigmultipart->typeparameters, g_strdup("boundary"),
                             g_strdup(boundary));
        g_hash_table_insert(sigmultipart->typeparameters, g_strdup("protocol"),