<<< Date Index >>>     <<< Thread Index >>>

Re: bug#1808: Bug#233106: mutt: hangs on ill-formatted mail



On 2004-02-26 10:21:33 +0100, Christoph Berg wrote:

> > > message-hook '!(~g|~G) ~b"^-----BEGIN\ PGP\ (SIGNED\ )?MESSAGE"' "exec 
> > > check-traditional-pgp"

The attached patch (which just went into the CVS) should make this
kind of message-hook safe, by making sure that check-traditional-pgp
does not leave the pager context.

-- 
Thomas Roessler                       <roessler@xxxxxxxxxxxxxxxxxx>
? err
? mutt-1.5.5-extra.tgz
? patch
? patch-1.5.3-CVS.tlr.idna.1
? patch-1.5.4.nr.tag_prefix_cond
? patch-1.5.4.tlr.nodots.1
? patch-1.5.4.tlr.pgpsmimeautoselect.1
? patch-1.5.4.tlr.query_mem.1
? patch-1.5.4.tlr.save_attachment.1
? patch-1.5.4.tlr.tag_prefix.1
? patch-1.5.5.1.regexp_lists.1
? patch-1.5.5.1.tlr.libidncompat.1
? patch-1.5.5.1.tlr.partsign.1
? patch-1.5.5.1.tlr.retainable_sigs.1
? patch-1.5.5.1.tlr.thread_free.1
? patch-1.5.5.1.tlr.unbind.1
? patch-1.5.5.1692
? patch-1.5.6.tlr.1808.1
? pgpring.sample
? send.c.new
? sort.c.new
? stamp-h1
? typescript
Index: commands.c
===================================================================
RCS file: /cvs/mutt/mutt/commands.c,v
retrieving revision 3.22
diff -u -r3.22 commands.c
--- commands.c  30 Dec 2003 13:04:20 -0000      3.22
+++ commands.c  12 Apr 2004 20:31:40 -0000
@@ -941,6 +941,8 @@
   MESSAGE *msg;
   int rv = 0;
   
+  h->security |= PGP_TRADITIONAL_CHECKED;
+  
   mutt_parse_mime_message (Context, h);
   if ((msg = mx_open_message (Context, h->msgno)) == NULL)
     return 0;
@@ -959,12 +961,12 @@
 {
   int i;
   int rv = 0;
-  if (h)
+  if (h && !(h->security & PGP_TRADITIONAL_CHECKED))
     rv = _mutt_check_traditional_pgp (h, redraw);
   else
   {
     for (i = 0; i < Context->vcount; i++)
-      if (Context->hdrs[Context->v2r[i]]->tagged)
+      if (Context->hdrs[Context->v2r[i]]->tagged && !(h->security & 
PGP_TRADITIONAL_CHECKED))
        rv = _mutt_check_traditional_pgp (Context->hdrs[Context->v2r[i]], 
redraw)
          || rv;
   }
Index: curs_main.c
===================================================================
RCS file: /cvs/mutt/mutt/curs_main.c,v
retrieving revision 3.16
diff -u -r3.16 curs_main.c
--- curs_main.c 3 Sep 2003 17:09:09 -0000       3.16
+++ curs_main.c 12 Apr 2004 20:31:40 -0000
@@ -1876,7 +1876,9 @@
           break;
         CHECK_MSGCOUNT; 
         CHECK_VISIBLE;
-        mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
+        if (tag || !(CURHDR->security & PGP_TRADITIONAL_CHECKED)) 
+         mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
+      
         if (menu->menu == MENU_PAGER)
         {
          op = OP_DISPLAY_MESSAGE;
Index: mutt.h
===================================================================
RCS file: /cvs/mutt/mutt/mutt.h,v
retrieving revision 3.24
diff -u -r3.24 mutt.h
--- mutt.h      12 Apr 2004 19:34:45 -0000      3.24
+++ mutt.h      12 Apr 2004 20:31:41 -0000
@@ -641,7 +641,7 @@
 
 typedef struct header
 {
-  unsigned int security : 9;  /* bit 0-6: flags, bit 7,8: application.
+  unsigned int security : 10;  /* bit 0-6: flags, bit 7,8: application.
                                 see: crypt.h pgplib.h, smime.h */
 
   unsigned int mime : 1;               /* has a Mime-Version header? */
Index: mutt_crypt.h
===================================================================
RCS file: /cvs/mutt/mutt/mutt_crypt.h,v
retrieving revision 3.5
diff -u -r3.5 mutt_crypt.h
--- mutt_crypt.h        30 Dec 2003 13:04:20 -0000      3.5
+++ mutt_crypt.h        12 Apr 2004 20:31:41 -0000
@@ -41,6 +41,8 @@
 #define APPLICATION_PGP    (1 << 7) 
 #define APPLICATION_SMIME  (1 << 8)
 
+#define PGP_TRADITIONAL_CHECKED (1 << 9)
+
 #define PGPENCRYPT  (APPLICATION_PGP | ENCRYPT)
 #define PGPSIGN     (APPLICATION_PGP | SIGN)
 #define PGPGOODSIGN (APPLICATION_PGP | GOODSIGN)
Index: pager.c
===================================================================
RCS file: /cvs/mutt/mutt/pager.c,v
retrieving revision 3.13
diff -u -r3.13 pager.c
--- pager.c     3 Dec 2003 08:19:11 -0000       3.13
+++ pager.c     12 Apr 2004 20:31:41 -0000
@@ -2173,6 +2173,17 @@
          mutt_resend_message (NULL, extra->ctx, extra->hdr);
         redraw = REDRAW_FULL;
         break;
+
+      case OP_CHECK_TRADITIONAL:
+        CHECK_MODE (IsHeader (extra));
+        if (!(WithCrypto & APPLICATION_PGP))
+         break;
+        if (!(extra->hdr->security & PGP_TRADITIONAL_CHECKED)) 
+        {
+         ch = -1;
+         rc = OP_CHECK_TRADITIONAL;
+       }
+        break;
       
       case OP_CREATE_ALIAS:
        CHECK_MODE(IsHeader (extra) || IsMsgAttach (extra));
Index: recvattach.c
===================================================================
RCS file: /cvs/mutt/mutt/recvattach.c,v
retrieving revision 3.12
diff -u -r3.12 recvattach.c
--- recvattach.c        4 Oct 2003 20:35:00 -0000       3.12
+++ recvattach.c        12 Apr 2004 20:31:42 -0000
@@ -816,7 +816,7 @@
        break;
       /* functions which are passed through from the pager */
       case OP_CHECK_TRADITIONAL:
-        if (!(WithCrypto & APPLICATION_PGP))
+        if (!(WithCrypto & APPLICATION_PGP) || (hdr && hdr->security & 
PGP_TRADITIONAL_CHECKED))
         {
           op = OP_NULL;
           break;

Attachment: pgpQVyVW5x2vt.pgp
Description: PGP signature