[PATCH] [BUGFIX] view attachments segfaults if decryption failed
Hi,
attached patch fixes a segfault I observed today: mutt failed to check for a
possible null pointer in mutt_is_application_smime(Body*).
Background: I received an S/MIME encrypted mail that the gpgme backend cannot
decrypt. (Error message "unsupported algorithm". I didn't have the time yet to
figure out what the problem is.) I wanted to check the mime-types of all
message parts whence I pressed 'v' ("view-attachments"). The result was that
mutt aborted due to a segfault without any further error message.
In the debugger I found that in mutt_view_attachments() the call to
crypt_smime_decrypt_mime() failed (recvattach.c, line 927) whence cur ==
0. The following function call mutt_is_application_smime(cur) dereferenced cur
and therefore segfaulted.
My patch makes mutt_is_application_smime(cur) return 0. In consequence the
test (need_secured && !secured) at the end of the function becomes true and
the user sees an error message.
Regards
Christoph
--
http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html
LiDIA: http://www.informatik.tu-darmstadt.de/TI/LiDIA/Welcome.html
Index: crypt.c
===================================================================
RCS file: /home/roessler/cvs/mutt/crypt.c,v
retrieving revision 3.26
diff -u -u -r3.26 crypt.c
--- crypt.c 3 Feb 2005 17:01:43 -0000 3.26
+++ crypt.c 4 Mar 2005 08:52:27 -0000
@@ -360,6 +360,9 @@
char *t=NULL;
int len, complain=0;
+ if(!m)
+ return 0;
+
if ((m->type & TYPEAPPLICATION) && m->subtype)
{
/* S/MIME MIME types don't need x- anymore, see RFC2311 */