From: David Levine Date: Fri, 21 Nov 2014 02:25:14 +0000 (-0600) Subject: Added some checks to mhfixmsg.c to avoid dereferecing null pointers X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/091316e666ccb2c628187888f7a48ad6d715d04a?ds=sidebyside Added some checks to mhfixmsg.c to avoid dereferecing null pointers after a failed transformation. --- diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index ffe97acd..31b3efe2 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -420,7 +420,7 @@ mhfixmsgsbr (CT *ctp, const fix_transformations *fx, char *outfile) { status = convert_charsets (*ctp, fx->textcharset, &message_mods); } - if (! (*ctp)->c_umask) { + if (status == OK && ! (*ctp)->c_umask) { /* Set the umask for the contents file. This currently isn't used but just in case it is in the future. */ struct stat st; @@ -474,7 +474,7 @@ fix_boundary (CT *ct, int *message_mods) { struct multipart *mp; int status = OK; - if (bogus_mp_content) { + if (ct && (*ct)->c_type == CT_MULTIPART && bogus_mp_content) { mp = (struct multipart *) (*ct)->c_ctparams; /* @@ -509,6 +509,7 @@ fix_boundary (CT *ct, int *message_mods) { "fix multipart boundary"); } } else { + *ct = NULL; advise (NULL, "unable to parse fixed part"); status = NOTOK; } @@ -996,7 +997,7 @@ build_text_plain_part (CT encoded_part) { } free_content (tp_part); - (void) m_unlink (tmp_plain_file); + if (tmp_plain_file) { (void) m_unlink (tmp_plain_file); } free (tmp_plain_file); return NULL;