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

decrypt-saving still deleting messages?



Hi all!

  Back in december Thomas fixed a bug which made decrypt-save delete the
  message even if the decryption hadn't been successful. The commit
  message was:

> 2004-12-21 09:46:24  Thomas Roessler  <roessler@xxxxxxxxxxxxxxxxxx>  
> (roessler)

>        * pgp.c: Fix Debian #275188.

  If you read the bug log, it seems that after some discussion between
  Thomas and Tamotsu, the bug was finally declared fixed (and they
  discovered that there was a remaining bug in the decode-save function).
  However, I can still reproduce the bug. Can anybody confirm?

  The patch, afaict, was:

--- a/pgp.c     2005-01-14 21:18:18 +01:00
+++ b/pgp.c     2005-01-14 21:18:18 +01:00
@@ -830,6 +830,10 @@
   *cur = pgp_decrypt_part (b, &s, *fpout, p);

   rewind (*fpout);
+
+  if (!*cur)
+    return -1;
+
   return (0);


   After some investigation, I've found that, while that fix was
   necessary, it is not enough, since pgp_decrypt_part(), in its current
   form, does never return NULL. This is because, unlike in the rest of
   pgp.c, the return of mutt_wait_filter() is not checked.

   I attach a patch that seems to fix the issue, comments welcome. I've
   checked that pgp_decrypt_part returning NULL is handled gracefully in
   the other invocation of it.

   Thanks.

-- 
Adeodato Simó
    EM: asp16 [ykwim] alu.ua.es | PK: DA6AE621
 
I don't want to achieve immortality through my work. I want to achieve
immortality throguh not dying.
                -- Woody Allen
--- pgp.c.orig  2005-01-16 03:35:03.000000000 +0100
+++ pgp.c       2005-01-16 04:08:46.000000000 +0100
@@ -721,7 +721,7 @@
   FILE *pgpin, *pgpout, *pgperr, *pgptmp;
   struct stat info;
   BODY *tattach;
-  int len;
+  int len, rv;
   char pgperrfile[_POSIX_PATH_MAX];
   char pgptmpfile[_POSIX_PATH_MAX];
   pid_t thepid;
@@ -780,7 +780,7 @@
   }
 
   fclose (pgpout);
-  mutt_wait_filter (thepid);
+  rv = mutt_wait_filter (thepid);
   mutt_unlink(pgptmpfile);
   
   if (s->flags & M_DISPLAY)
@@ -808,6 +808,9 @@
     mutt_parse_part (fpout, tattach);
   }
 
+  if (rv)
+    return NULL;
+
   return (tattach);
 }