]> granicus.if.org Git - mutt/commitdiff
Add error results to mutt_body_handlers, and check them when doing
authorBrendan Cully <brendan@kublai.com>
Thu, 11 Aug 2005 21:16:38 +0000 (21:16 +0000)
committerBrendan Cully <brendan@kublai.com>
Thu, 11 Aug 2005 21:16:38 +0000 (21:16 +0000)
decode-save. Closes: #1919.

17 files changed:
copy.c
crypt-gpgme.c
crypt-gpgme.h
crypt-mod-pgp-classic.c
crypt-mod-pgp-gpgme.c
crypt-mod-smime-classic.c
crypt-mod-smime-gpgme.c
crypt-mod.h
crypt.c
cryptglue.c
handler.c
mutt_crypt.h
pgp.c
pgp.h
protos.h
smime.c
smime.h

diff --git a/copy.c b/copy.c
index a5777c083127ad0f9b955c1ad6f28e219b34d4d0..8dbec08c6e34e5b9ff7d15e216ba857bf20018d0 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -546,6 +546,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
   char prefix[SHORT_STRING];
   STATE s;
   long new_offset = -1;
+  int rc = 0;
 
   if (flags & M_CM_PREFIX)
   {
@@ -657,7 +658,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
     if (WithCrypto && flags & M_CM_VERIFY)
       s.flags |= M_VERIFY;
 
-    mutt_body_handler (body, &s);
+    rc = mutt_body_handler (body, &s);
   }
   else if (WithCrypto
            && (flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT))
@@ -725,7 +726,7 @@ _mutt_copy_message (FILE *fpout, FILE *fpin, HEADER *hdr, BODY *body,
     mutt_free_body (&body->parts);
   }
 
-  return 0;
+  return rc;
 }
 
 int
index 54773b69007cdde206a33dcf8e0f71ed8ef57938..feb28ed93dd79a09a794828947b5f4f65e827834 100644 (file)
@@ -1882,7 +1882,7 @@ static void copy_clearsigned (gpgme_data_t data, STATE *s, char *charset)
 
 
 /* Support for classic_application/pgp */
-void pgp_gpgme_application_handler (BODY *m, STATE *s)
+int pgp_gpgme_application_handler (BODY *m, STATE *s)
 {
   int needpass = -1, pgp_keyblock = 0;
   int clearsign = 0;
@@ -1891,7 +1891,7 @@ void pgp_gpgme_application_handler (BODY *m, STATE *s)
   char buf[HUGE_STRING];
   FILE *pgpout = NULL;
 
-  gpgme_error_t err;
+  gpgme_error_t err = 0;
   gpgme_data_t armored_data = NULL;
 
   short maybe_goodsig = 1;
@@ -2130,9 +2130,11 @@ void pgp_gpgme_application_handler (BODY *m, STATE *s)
     {
       state_attach_puts (_("[-- Error: could not find beginning"
                            " of PGP message! --]\n\n"), s);
-      return;
+      return -1;
     }
   dprint (2, (debugfile, "Leaving pgp_application_pgp handler\n"));
+
+  return err;
 }
 
 /* 
@@ -2140,13 +2142,14 @@ void pgp_gpgme_application_handler (BODY *m, STATE *s)
  */
 
 /* MIME handler for pgp/mime encrypted messages. */
-void pgp_gpgme_encrypted_handler (BODY *a, STATE *s)
+int pgp_gpgme_encrypted_handler (BODY *a, STATE *s)
 {
   char tempfile[_POSIX_PATH_MAX];
   FILE *fpout;
   BODY *tattach;
   BODY *orig_body = a;
   int is_signed;
+  int rc = 0;
   
   dprint (2, (debugfile, "Entering pgp_encrypted handler\n"));
   a = a->parts;
@@ -2158,7 +2161,7 @@ void pgp_gpgme_encrypted_handler (BODY *a, STATE *s)
       if (s->flags & M_DISPLAY)
         state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"),
                            s);
-      return;
+      return -1;
     }
 
   /* Move forward to the application/pgp-encrypted body. */
@@ -2170,7 +2173,7 @@ void pgp_gpgme_encrypted_handler (BODY *a, STATE *s)
       if (s->flags & M_DISPLAY)
         state_attach_puts (_("[-- Error: could not create temporary file! "
                              "--]\n"), s);
-      return;
+      return -1;
     }
 
   tattach = decrypt_part (a, s, fpout, 0, &is_signed);
@@ -2187,7 +2190,7 @@ void pgp_gpgme_encrypted_handler (BODY *a, STATE *s)
       {
         FILE *savefp = s->fpin;
         s->fpin = fpout;
-        mutt_body_handler (tattach, s);
+        rc = mutt_body_handler (tattach, s);
         s->fpin = savefp;
       }
 
@@ -2214,16 +2217,18 @@ void pgp_gpgme_encrypted_handler (BODY *a, STATE *s)
   fclose (fpout);
   mutt_unlink(tempfile);
   dprint (2, (debugfile, "Leaving pgp_encrypted handler\n"));
+
+  return rc;
 }
 
 /* Support for application/smime */
-void smime_gpgme_application_handler (BODY *a, STATE *s)
+int smime_gpgme_application_handler (BODY *a, STATE *s)
 {
   char tempfile[_POSIX_PATH_MAX];
   FILE *fpout;
   BODY *tattach;
   int is_signed;
-
+  int rc = 0;
 
   dprint (2, (debugfile, "Entering smime_encrypted handler\n"));
   
@@ -2234,7 +2239,7 @@ void smime_gpgme_application_handler (BODY *a, STATE *s)
       if (s->flags & M_DISPLAY)
         state_attach_puts (_("[-- Error: could not create temporary file! "
                              "--]\n"), s);
-      return;
+      return -1;
     }
 
   tattach = decrypt_part (a, s, fpout, 1, &is_signed);
@@ -2251,7 +2256,7 @@ void smime_gpgme_application_handler (BODY *a, STATE *s)
       {
         FILE *savefp = s->fpin;
         s->fpin = fpout;
-        mutt_body_handler (tattach, s);
+        rc = mutt_body_handler (tattach, s);
         s->fpin = savefp;
       }
 
@@ -2286,6 +2291,8 @@ void smime_gpgme_application_handler (BODY *a, STATE *s)
   fclose (fpout);
   mutt_unlink(tempfile);
   dprint (2, (debugfile, "Leaving smime_encrypted handler\n"));
+  
+  return rc;
 }
 
 
index 49013515d82611bd7c71d674b2365ecd44307827..0d66ddff74157703adb4078f53436558cd1ac8ca 100644 (file)
@@ -35,9 +35,9 @@ int smime_gpgme_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur);
 
 int pgp_gpgme_check_traditional (FILE *fp, BODY *b, int tagged_only);
 
-void pgp_gpgme_application_handler (BODY *m, STATE *s);
-void smime_gpgme_application_handler (BODY *a, STATE *s);
-void pgp_gpgme_encrypted_handler (BODY *a, STATE *s);
+int pgp_gpgme_application_handler (BODY *m, STATE *s);
+int smime_gpgme_application_handler (BODY *a, STATE *s);
+int pgp_gpgme_encrypted_handler (BODY *a, STATE *s);
 
 BODY *pgp_gpgme_make_key_attachment (char *tempf);
 
@@ -50,4 +50,5 @@ int smime_gpgme_verify_one (BODY *sigbdy, STATE *s, const char *tempfile);
 int pgp_gpgme_send_menu (HEADER *msg, int *redraw);
 int smime_gpgme_send_menu (HEADER *msg, int *redraw);
 
+int smime_gpgme_verify_sender (HEADER *h);
 #endif
index e6e3bc809e009213e48bfacdfa56965cb0244ef9..d3b471b61ab66601e7b174cdd819624018018bd8 100644 (file)
@@ -41,9 +41,9 @@ static int crypt_mod_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
 {
   return pgp_decrypt_mime (a, b, c, d);
 }
-static void crypt_mod_pgp_application_handler (BODY *m, STATE *s)
+static int crypt_mod_pgp_application_handler (BODY *m, STATE *s)
 {
-  pgp_application_pgp_handler (m, s);
+  return pgp_application_pgp_handler (m, s);
 }
 
 static char *crypt_mod_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
@@ -86,9 +86,9 @@ static BODY *crypt_mod_pgp_traditional_encryptsign (BODY *a, int flags, char *ke
   return pgp_traditional_encryptsign (a, flags, keylist);
 }
 
-static void crypt_mod_pgp_encrypted_handler (BODY *m, STATE *s)
+static int crypt_mod_pgp_encrypted_handler (BODY *m, STATE *s)
 {
-  pgp_encrypted_handler (m, s);
+  return pgp_encrypted_handler (m, s);
 }
 
 static void crypt_mod_pgp_invoke_getkeys (ADDRESS *addr)
index bab9663a4fa79d83b572bed57494236cee2a31d9..45e5b9c810faa6832d9ddd9b9c53d5a1bc2e15e3 100644 (file)
@@ -50,14 +50,14 @@ static int crypt_mod_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
   return pgp_gpgme_decrypt_mime (a, b, c, d);
 }
 
-static void crypt_mod_pgp_application_handler (BODY *m, STATE *s)
+static int crypt_mod_pgp_application_handler (BODY *m, STATE *s)
 {
-  pgp_gpgme_application_handler (m, s);
+  return pgp_gpgme_application_handler (m, s);
 }
 
-static void crypt_mod_pgp_encrypted_handler (BODY *m, STATE *s)
+static int crypt_mod_pgp_encrypted_handler (BODY *m, STATE *s)
 {
-  pgp_gpgme_encrypted_handler (m, s);
+  return pgp_gpgme_encrypted_handler (m, s);
 }
 
 static int crypt_mod_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
index cff63b24004d06301e3513a5bdafbea9d3fc8352..0d038732ef15804677918445818cfe421604b539 100644 (file)
@@ -41,9 +41,9 @@ static int crypt_mod_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
 {
   return smime_decrypt_mime (a, b, c, d);
 }
-static void crypt_mod_smime_application_handler (BODY *m, STATE *s)
+static int crypt_mod_smime_application_handler (BODY *m, STATE *s)
 {
-  smime_application_smime_handler (m, s);
+  return smime_application_smime_handler (m, s);
 }
 
 static char *crypt_mod_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
index 761dec9135bd40b328d90d981565167d4f97bf4f..8b180c2b92d0b1b8f5e50d3b072c6c251b406219 100644 (file)
@@ -50,9 +50,9 @@ static int crypt_mod_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
   return smime_gpgme_decrypt_mime (a, b, c, d);
 }
 
-static void crypt_mod_smime_application_handler (BODY *m, STATE *s)
+static int crypt_mod_smime_application_handler (BODY *m, STATE *s)
 {
-  smime_gpgme_application_handler (m, s);
+  return smime_gpgme_application_handler (m, s);
 }
 
 static char *crypt_mod_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
index 4f69c3e853fc1066da4fb064bfd832e365c4ffaf..133b784bce4f822968d1a79dcf283d109f0d0ab5 100644 (file)
@@ -34,8 +34,8 @@ typedef int (*crypt_func_valid_passphrase_t)  (void);
 typedef int (*crypt_func_decrypt_mime_t) (FILE *a, FILE **b,
                                           BODY *c, BODY **d);
 
-typedef void (*crypt_func_application_handler_t) (BODY *m, STATE *s);
-typedef void (*crypt_func_encrypted_handler_t) (BODY *m, STATE *s);
+typedef int (*crypt_func_application_handler_t) (BODY *m, STATE *s);
+typedef int (*crypt_func_encrypted_handler_t) (BODY *m, STATE *s);
 
 typedef void (*crypt_func_pgp_invoke_getkeys_t) (ADDRESS *addr);
 typedef int (*crypt_func_pgp_check_traditional_t) (FILE *fp, BODY *b,
diff --git a/crypt.c b/crypt.c
index dfe64d37652b7f97aab9247f0dd73258dff10028..ca2fb047219a195e084182c8cd988a251b87c1d1 100644 (file)
--- a/crypt.c
+++ b/crypt.c
@@ -758,7 +758,7 @@ static void crypt_fetch_signatures (BODY ***signatures, BODY *a, int *n)
  * This routine verifies a  "multipart/signed"  body.
  */
 
-void mutt_signed_handler (BODY *a, STATE *s)
+int mutt_signed_handler (BODY *a, STATE *s)
 {
   char tempfile[_POSIX_PATH_MAX];
   char *protocol;
@@ -770,9 +770,10 @@ void mutt_signed_handler (BODY *a, STATE *s)
   int sigcnt = 0;
   int i;
   short goodsig = 1;
+  int rc = 0;
 
   if (!WithCrypto)
-    return;
+    return -1;
 
   protocol = mutt_get_parameter ("protocol", a->parameter);
   a = a->parts;
@@ -801,8 +802,7 @@ void mutt_signed_handler (BODY *a, STATE *s)
     state_attach_puts (_("[-- Error: "
                          "Inconsistent multipart/signed structure! --]\n\n"),
                        s);
-    mutt_body_handler (a, s);
-    return;
+    return mutt_body_handler (a, s);
   }
 
   
@@ -823,8 +823,7 @@ void mutt_signed_handler (BODY *a, STATE *s)
     state_printf (s, _("[-- Error: "
                        "Unknown multipart/signed protocol %s! --]\n\n"),
                   protocol);
-    mutt_body_handler (a, s);
-    return;
+    return mutt_body_handler (a, s);
   }
   
   if (s->flags & M_DISPLAY)
@@ -881,10 +880,12 @@ void mutt_signed_handler (BODY *a, STATE *s)
       state_attach_puts (_("[-- Warning: Can't find any signatures. --]\n\n"), s);
   }
   
-  mutt_body_handler (a, s);
+  rc = mutt_body_handler (a, s);
   
   if (s->flags & M_DISPLAY && sigcnt)
     state_attach_puts (_("\n[-- End of signed data --]\n"), s);
+  
+  return rc;
 }
 
 
index f6a1bab35b01d6385e3bff764121732f9a9aad2e..e98e8625f2cace788478b48fc7eadc4b8636c322 100644 (file)
@@ -147,17 +147,21 @@ int crypt_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
 }
 
 /* MIME handler for the application/pgp content-type. */
-void crypt_pgp_application_pgp_handler (BODY *m, STATE *s)
+int crypt_pgp_application_pgp_handler (BODY *m, STATE *s)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, application_handler))
-    (CRYPT_MOD_CALL (PGP, application_handler)) (m, s);
+    return (CRYPT_MOD_CALL (PGP, application_handler)) (m, s);
+  
+  return -1;
 }
 
 /* MIME handler for an PGP/MIME encrypted message. */
-void crypt_pgp_encrypted_handler (BODY *a, STATE *s)
+int crypt_pgp_encrypted_handler (BODY *a, STATE *s)
 {
   if (CRYPT_MOD_CALL_CHECK (PGP, encrypted_handler))
-    (CRYPT_MOD_CALL (PGP, encrypted_handler)) (a, s);
+    return (CRYPT_MOD_CALL (PGP, encrypted_handler)) (a, s);
+  
+  return -1;
 }
 
 /* fixme: needs documentation. */
@@ -290,10 +294,12 @@ int crypt_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
 }
 
 /* MIME handler for the application/smime content-type. */
-void crypt_smime_application_smime_handler (BODY *m, STATE *s)
+int crypt_smime_application_smime_handler (BODY *m, STATE *s)
 {
   if (CRYPT_MOD_CALL_CHECK (SMIME, application_handler))
-    (CRYPT_MOD_CALL (SMIME, application_handler)) (m, s);
+    return (CRYPT_MOD_CALL (SMIME, application_handler)) (m, s);
+  
+  return -1;
 }
 
 /* MIME handler for an PGP/MIME encrypted message. */
index 8dfb769ddf4d2940182a20c68d63967171e7a148..e7c3e3230654e1face00438e7f387f4e87e56461 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -41,8 +41,7 @@
 #define BUFO_SIZE 2000
 
 
-typedef void handler_f (BODY *, STATE *);
-typedef handler_f *handler_t;
+typedef int (*handler_t) (BODY *, STATE *);
 
 int Index_hex[128] = {
     -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
@@ -767,7 +766,7 @@ static void enriched_set_flags (const char *tag, struct enriched_state *stte)
   }
 }
 
-void text_enriched_handler (BODY *a, STATE *s)
+int text_enriched_handler (BODY *a, STATE *s)
 {
   enum {
     TEXT, LANGLE, TAG, BOGUS_TAG, NEWLINE, ST_EOF, DONE
@@ -889,6 +888,8 @@ void text_enriched_handler (BODY *a, STATE *s)
   FREE (&(stte.buffer));
   FREE (&(stte.line));
   FREE (&(stte.param));
+
+  return 0;
 }                                                                              
 
 /*
@@ -963,7 +964,7 @@ static int flowed_visual_strlen (char *l, int i)
   return j;
 }
 
-static void text_plain_flowed_handler (BODY *a, STATE *s)
+static int text_plain_flowed_handler (BODY *a, STATE *s)
 {
   char line[LONG_STRING];
   char indent[LONG_STRING];
@@ -1185,7 +1186,8 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
 
   if (col)
     state_putc ('\n', s);
-  
+
+  return 0;
 }
 
 
@@ -1197,7 +1199,7 @@ static void text_plain_flowed_handler (BODY *a, STATE *s)
 #define TXTPLAIN    2
 #define TXTENRICHED 3
 
-static void alternative_handler (BODY *a, STATE *s)
+static int alternative_handler (BODY *a, STATE *s)
 {
   BODY *choice = NULL;
   BODY *b;
@@ -1205,6 +1207,7 @@ static void alternative_handler (BODY *a, STATE *s)
   char buf[STRING];
   int type = 0;
   int mustfree = 0;
+  int rc = 0;
 
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
       a->encoding == ENCUUENCODED)
@@ -1347,18 +1350,22 @@ static void alternative_handler (BODY *a, STATE *s)
     /* didn't find anything that we could display! */
     state_mark_attach (s);
     state_puts(_("[-- Error:  Could not display any parts of Multipart/Alternative! --]\n"), s);
+    rc = -1;
   }
 
   if (mustfree)
     mutt_free_body(&a);
+
+  return rc;
 }
 
 /* handles message/rfc822 body parts */
-void message_handler (BODY *a, STATE *s)
+int message_handler (BODY *a, STATE *s)
 {
   struct stat st;
   BODY *b;
   long off_start;
+  int rc = 0;
 
   off_start = ftell (s->fpin);
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE || 
@@ -1382,12 +1389,14 @@ void message_handler (BODY *a, STATE *s)
       state_puts (s->prefix, s);
     state_putc ('\n', s);
 
-    mutt_body_handler (b->parts, s);
+    rc = mutt_body_handler (b->parts, s);
   }
 
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
       a->encoding == ENCUUENCODED)
     mutt_free_body (&b);
+  
+  return rc;
 }
 
 /* returns 1 if decoding the attachment will produce output */
@@ -1431,12 +1440,13 @@ int mutt_can_decode (BODY *a)
   return (0);
 }
 
-void multipart_handler (BODY *a, STATE *s)
+int multipart_handler (BODY *a, STATE *s)
 {
   BODY *b, *p;
   char length[5];
   struct stat st;
   int count;
+  int rc = 0;
 
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
       a->encoding == ENCUUENCODED)
@@ -1487,19 +1497,21 @@ void multipart_handler (BODY *a, STATE *s)
        state_printf(s, "%s: \n", p->form_name);
 
     }
-    mutt_body_handler (p, s);
+    rc = mutt_body_handler (p, s);
     state_putc ('\n', s);
-    if ((s->flags & M_REPLYING)
-       && (option (OPTINCLUDEONLYFIRST)) && (s->flags & M_FIRSTDONE))
+    if (rc || ((s->flags & M_REPLYING)
+               && (option (OPTINCLUDEONLYFIRST)) && (s->flags & M_FIRSTDONE)))
       break;
   }
 
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
       a->encoding == ENCUUENCODED)
     mutt_free_body (&b);
+  
+  return rc;
 }
 
-void autoview_handler (BODY *a, STATE *s)
+int autoview_handler (BODY *a, STATE *s)
 {
   rfc1524_entry *entry = rfc1524_new_entry ();
   char buffer[LONG_STRING];
@@ -1512,6 +1524,7 @@ void autoview_handler (BODY *a, STATE *s)
   FILE *fperr = NULL;
   int piped = FALSE;
   pid_t thepid;
+  int rc = 0;
 
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
   rfc1524_mailcap_lookup (a, type, entry, M_AUTOVIEW);
@@ -1539,7 +1552,7 @@ void autoview_handler (BODY *a, STATE *s)
     {
       mutt_perror ("fopen");
       rfc1524_free_entry (&entry);
-      return;
+      return -1;
     }
     
     mutt_copy_bytes (s->fpin, fpin, a->length);
@@ -1566,6 +1579,7 @@ void autoview_handler (BODY *a, STATE *s)
        state_mark_attach (s);
        state_printf (s, _("[-- Can't run %s. --]\n"), command);
       }
+      rc = -1;
       goto bail;
     }
     
@@ -1626,9 +1640,11 @@ void autoview_handler (BODY *a, STATE *s)
       mutt_clear_error ();
   }
   rfc1524_free_entry (&entry);
+
+  return rc;
 }
 
-static void external_body_handler (BODY *b, STATE *s)
+static int external_body_handler (BODY *b, STATE *s)
 {
   const char *access_type;
   const char *expiration;
@@ -1642,7 +1658,7 @@ static void external_body_handler (BODY *b, STATE *s)
       state_mark_attach (s);
       state_puts (_("[-- Error: message/external-body has no access-type parameter --]\n"), s);
     }
-    return;
+    return -1;
   }
 
   expiration = mutt_get_parameter ("expiration", b->parameter);
@@ -1718,6 +1734,8 @@ static void external_body_handler (BODY *b, STATE *s)
                     CH_DECODE , NULL);
     }
   }
+  
+  return 0;
 }
 
 void mutt_decode_attachment (BODY *b, STATE *s)
@@ -1753,7 +1771,7 @@ void mutt_decode_attachment (BODY *b, STATE *s)
     iconv_close (cd);
 }
 
-void mutt_body_handler (BODY *b, STATE *s)
+int mutt_body_handler (BODY *b, STATE *s)
 {
   int decode = 0;
   int plaintext = 0;
@@ -1763,6 +1781,7 @@ void mutt_body_handler (BODY *b, STATE *s)
   long tmpoffset = 0;
   size_t tmplength = 0;
   char type[STRING];
+  int rc = 0;
 
   int oflags = s->flags;
   
@@ -1913,7 +1932,7 @@ void mutt_body_handler (BODY *b, STATE *s)
     /* process the (decoded) body part */
     if (handler)
     {
-      handler (b, s);
+      rc = handler (b, s);
 
       if (decode)
       {
@@ -1941,7 +1960,9 @@ void mutt_body_handler (BODY *b, STATE *s)
     }
     fputs (" --]\n", s->fpout);
   }
-  
+
   bail:
   s->flags = oflags | (s->flags & M_FIRSTDONE);
+
+  return rc;
 }
index 6b57382ec03433b8ca5116b6bec1b3ffbc337ff4..acb356fe08024ddeff203dc7b1ec1982f6f0a1ca 100644 (file)
@@ -117,7 +117,7 @@ int mutt_is_application_pgp (BODY *);
 
 int mutt_is_application_smime (BODY *);
 
-void mutt_signed_handler (BODY *, STATE *);
+int mutt_signed_handler (BODY *, STATE *);
 
 int mutt_parse_crypt_hdr (char *, int);
 
@@ -171,10 +171,10 @@ int crypt_pgp_valid_passphrase (void);
 int crypt_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d);
 
 /* MIME handler for the application/pgp content-type. */
-void crypt_pgp_application_pgp_handler (BODY *m, STATE *s);
+int crypt_pgp_application_pgp_handler (BODY *m, STATE *s);
 
 /* MIME handler for an PGP/MIME encrypted message. */
-void crypt_pgp_encrypted_handler (BODY *a, STATE *s);
+int crypt_pgp_encrypted_handler (BODY *a, STATE *s);
 
 /* fixme: needs documentation. */
 void crypt_pgp_invoke_getkeys (ADDRESS *addr);
@@ -233,7 +233,7 @@ int crypt_smime_valid_passphrase (void);
 int crypt_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d);
 
 /* MIME handler for the application/smime content-type. */
-void crypt_smime_application_smime_handler (BODY *m, STATE *s);
+int crypt_smime_application_smime_handler (BODY *m, STATE *s);
 
 /* fixme: Needs documentation. */
 void crypt_smime_getkeys (ENVELOPE *env);
diff --git a/pgp.c b/pgp.c
index 587ab73cb82cefc130d2ae785fcfff7fe708148b..ac482baad1d68bf9de7cc30fea50d625be1c3a2a 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -233,7 +233,7 @@ static void pgp_copy_clearsigned (FILE *fpin, STATE *s, char *charset)
 
 /* Support for the Application/PGP Content Type. */
 
-void pgp_application_pgp_handler (BODY *m, STATE *s)
+int pgp_application_pgp_handler (BODY *m, STATE *s)
 {
   int needpass = -1, pgp_keyblock = 0;
   int clearsign = 0, rv, rc;
@@ -301,7 +301,7 @@ void pgp_application_pgp_handler (BODY *m, STATE *s)
       if ((tmpfp = safe_fopen (tmpfname, "w+")) == NULL)
       {
        mutt_perror (tmpfname);
-       return;
+       return -1;
       }
       
       fputs (buf, tmpfp);
@@ -331,7 +331,7 @@ void pgp_application_pgp_handler (BODY *m, STATE *s)
        if ((pgpout = safe_fopen (outfile, "w+")) == NULL)
        {
          mutt_perror (tmpfname);
-         return;
+         return -1;
        }
        
        if ((thepid = pgp_invoke_decode (&pgpin, NULL, &pgperr, -1,
@@ -386,6 +386,7 @@ void pgp_application_pgp_handler (BODY *m, STATE *s)
        {
           mutt_error _("Could not decrypt PGP message");
           pgp_void_passphrase ();
+          rc = -1;
           
           goto out;
         }
@@ -449,6 +450,8 @@ void pgp_application_pgp_handler (BODY *m, STATE *s)
     }
   }
 
+  rc = 0;
+
 out:
   m->goodsig = (maybe_goodsig && have_any_sigs);
 
@@ -466,8 +469,10 @@ out:
   if (needpass == -1)
   {
     state_attach_puts (_("[-- Error: could not find beginning of PGP message! --]\n\n"), s);
-    return;
+    return -1;
   }
+  
+  return rc;
 }
 
 static int pgp_check_traditional_one_body (FILE *fp, BODY *b, int tagged_only)
@@ -819,7 +824,11 @@ BODY *pgp_decrypt_part (BODY *a, STATE *s, FILE *fpout, BODY *p)
   rewind (fpout);
   
   if (fgetc (fpout) == EOF)
+  {
+    mutt_error _("Decryption failed");
+    pgp_void_passphrase ();
     return NULL;
+  }
 
   rewind (fpout);
   
@@ -873,12 +882,13 @@ int pgp_decrypt_mime (FILE *fpin, FILE **fpout, BODY *b, BODY **cur)
   return (0);
 }
 
-void pgp_encrypted_handler (BODY *a, STATE *s)
+int pgp_encrypted_handler (BODY *a, STATE *s)
 {
   char tempfile[_POSIX_PATH_MAX];
   FILE *fpout, *fpin;
   BODY *tattach;
   BODY *p = a;
+  int rc = 0;
   
   a = a->parts;
   if (!a || a->type != TYPEAPPLICATION || !a->subtype || 
@@ -888,7 +898,7 @@ void pgp_encrypted_handler (BODY *a, STATE *s)
   {
     if (s->flags & M_DISPLAY)
       state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"), s);
-    return;
+    return -1;
   }
 
   /*
@@ -901,7 +911,7 @@ void pgp_encrypted_handler (BODY *a, STATE *s)
   {
     if (s->flags & M_DISPLAY)
       state_attach_puts (_("[-- Error: could not create temporary file! --]\n"), s);
-    return;
+    return -1;
   }
 
   if (s->flags & M_DISPLAY) crypt_current_time (s, "PGP");
@@ -913,7 +923,7 @@ void pgp_encrypted_handler (BODY *a, STATE *s)
 
     fpin = s->fpin;
     s->fpin = fpout;
-    mutt_body_handler (tattach, s);
+    rc = mutt_body_handler (tattach, s);
     s->fpin = fpin;
 
     /* 
@@ -941,10 +951,13 @@ void pgp_encrypted_handler (BODY *a, STATE *s)
     mutt_error _("Could not decrypt PGP message");
     /* void the passphrase, even if it's not necessarily the problem */
     pgp_void_passphrase ();
+    rc = -1;
   }
 
   fclose (fpout);
   mutt_unlink(tempfile);
+
+  return rc;
 }
 
 /* ----------------------------------------------------------------------------
diff --git a/pgp.h b/pgp.h
index 31718720d072cd10e4dc2515b004419a7d2fc8d8..52d930f5b623d6959f434f2a46024ef725d172ea 100644 (file)
--- a/pgp.h
+++ b/pgp.h
@@ -52,8 +52,8 @@ pgp_key_t pgp_getkeybystr (char *, short, pgp_ring_t);
 char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
 
 void pgp_forget_passphrase (void);
-void pgp_application_pgp_handler (BODY *, STATE *);
-void pgp_encrypted_handler (BODY *, STATE *);
+int pgp_application_pgp_handler (BODY *, STATE *);
+int pgp_encrypted_handler (BODY *, STATE *);
 void pgp_extract_keys_from_attachment_list (FILE * fp, int tag, BODY * top);
 void pgp_void_passphrase (void);
 int pgp_valid_passphrase (void);
index 5b23ee4bbcff931933c306e7153786be50a4d3b5..faa6a2fa009568ee24a1caf003ee207a952fc19e 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -161,7 +161,7 @@ void mutt_allow_interrupt (int);
 void mutt_attach_init (BODY *);
 void mutt_block_signals (void);
 void mutt_block_signals_system (void);
-void mutt_body_handler (BODY *, STATE *);
+int mutt_body_handler (BODY *, STATE *);
 int  mutt_bounce_message (FILE *fp, HEADER *, ADDRESS *);
 void mutt_break_thread (HEADER *);
 void mutt_buffy (char *, size_t);
diff --git a/smime.c b/smime.c
index 7cbd987aba8365838be5196bcb74368ea44904f6..476484e4c086e6dd9b143e51f84641c281af09d6 100644 (file)
--- a/smime.c
+++ b/smime.c
@@ -1929,11 +1929,9 @@ bail:
 }
 
 
-void smime_application_smime_handler (BODY *m, STATE *s)
+int smime_application_smime_handler (BODY *m, STATE *s)
 {
-    
-    smime_handle_entity (m, s, NULL);
-
+  return smime_handle_entity (m, s, NULL) ? 0 : -1;
 }
 
 int smime_send_menu (HEADER *msg, int *redraw)
diff --git a/smime.h b/smime.h
index dba0a0fc4ff3c928180602b7287568333fcffb35..1381294550b7b22b0b0c7c9fc8f88a7c4674fa52 100644 (file)
--- a/smime.h
+++ b/smime.h
@@ -31,7 +31,7 @@ int smime_valid_passphrase (void);
 
 int   smime_decrypt_mime (FILE *, FILE **, BODY *, BODY **);
 
-void  smime_application_smime_handler (BODY *, STATE *);
+int  smime_application_smime_handler (BODY *, STATE *);
 
 
 BODY* smime_sign_message (BODY *);