]> granicus.if.org Git - neomutt/commitdiff
Fix verification of clearsigned PGP messages. (debugged on IRC,
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 11 Aug 2005 21:08:55 +0000 (21:08 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 11 Aug 2005 21:08:55 +0000 (21:08 +0000)
mostly by Brendan)

pgp.c

diff --git a/pgp.c b/pgp.c
index 55f90ce94b95fd78f7c47bb3945d5d7f2b663d20..587ab73cb82cefc130d2ae785fcfff7fe708148b 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -237,13 +237,14 @@ void pgp_application_pgp_handler (BODY *m, STATE *s)
 {
   int needpass = -1, pgp_keyblock = 0;
   int clearsign = 0, rv, rc;
+  int c;
   long start_pos = 0;
   long bytes, last_pos, offset;
   char buf[HUGE_STRING];
   char outfile[_POSIX_PATH_MAX];
   char tmpfname[_POSIX_PATH_MAX];
   FILE *pgpout = NULL, *pgpin = NULL, *pgperr = NULL;
-  FILE *tmpfp;
+  FILE *tmpfp = NULL;
   pid_t thepid;
 
   short maybe_goodsig = 1;
@@ -367,26 +368,28 @@ void pgp_application_pgp_handler (BODY *m, STATE *s)
          if (s->flags & M_DISPLAY)
          {
            if (rc == 0) have_any_sigs = 1;
-/*
- * Sig is bad if
- * gpg_good_sign-pattern did not match || pgp_decode_command returned not 0
- * Sig _is_ correct if
- *  gpg_good_sign="" && pgp_decode_command returned 0
- */
+           /*
           * Sig is bad if
           * gpg_good_sign-pattern did not match || pgp_decode_command returned not 0
           * Sig _is_ correct if
           *  gpg_good_sign="" && pgp_decode_command returned 0
           */
            if (rc == -1 || rv) maybe_goodsig = 0;
-
+           
            state_attach_puts (_("[-- End of PGP output --]\n\n"), s);
          }
        }
-
+       
         /* treat empty result as sign of failure */
-        if (!(pgpout && ftell(pgpout)))
-        {
+       rewind (pgpout);
+        if ((c = fgetc (pgpout)) == EOF)
+       {
           mutt_error _("Could not decrypt PGP message");
           pgp_void_passphrase ();
           
           goto out;
         }
+       ungetc (c, pgpout);
       }
       
       /*