From: Pierre Habouzit Date: Wed, 13 Dec 2006 13:41:49 +0000 (+0100) Subject: some fixes, make mutt_decode_save_attachment coherent (always closes the X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=a4e6d1eb7521b75921259ae370607074dde0e765;p=apps%2Fmadmutt.git some fixes, make mutt_decode_save_attachment coherent (always closes the fd). Signed-off-by: Pierre Habouzit --- diff --git a/attach.c b/attach.c index 7bc9c43..d4aa0d3 100644 --- a/attach.c +++ b/attach.c @@ -507,6 +507,8 @@ int mutt_view_attachment (FILE * fp, BODY * a, int flag, HEADER * hdr, /* Don't use mailcap; the attachment is viewed in the pager */ if (flag == M_AS_TEXT) { + unlink(pagerfile); + close(pagerfd); /* just let me see the raw data */ if (mutt_save_attachment (fp, a, pagerfile, 0, NULL)) goto return_error; @@ -775,10 +777,10 @@ int mutt_decode_save_attachment (FILE * fp, BODY * m, int pathfd, p_clear(&s, 1); s.flags = displaying; - s.fpout = fdopen (pathfd, "w"); if (s.fpout == NULL) { + close(pathfd); mutt_perror ("fopen"); return (-1); } @@ -924,7 +926,8 @@ int mutt_print_attachment (FILE * fp, BODY * a) if (tok == MIME_TEXT_PLAIN || tok == MIME_APPLICATION_POSTSCRIPT) { return (mutt_pipe_attachment (fp, a, NONULL (PrintCmd), NULL)); } - else if (mutt_can_decode (a)) { + + if (mutt_can_decode (a)) { /* decode and print */ int rc = 0; @@ -936,7 +939,7 @@ int mutt_print_attachment (FILE * fp, BODY * a) newfile_fd = m_tempfd(newfile, sizeof(newfile), NONULL(Tempdir), NULL); if (mutt_decode_save_attachment (fp, a, newfile_fd, M_PRINTING) == 0) { - if ((ifp = fdopen (newfile_fd, "r")) == NULL) { + if ((ifp = fopen(newfile, "r")) == NULL) { mutt_perror ("fopen"); goto bail0; } @@ -949,8 +952,7 @@ int mutt_print_attachment (FILE * fp, BODY * a) goto bail0; } - mutt_copy_stream (ifp, fpout); - + mutt_copy_stream(ifp, fpout); m_fclose(&fpout); m_fclose(&ifp); @@ -963,8 +965,7 @@ int mutt_print_attachment (FILE * fp, BODY * a) m_fclose(&fpout); mutt_unlink (newfile); return rc; - } - else { + } else { mutt_error _("I don't know how to print that!"); return 0; diff --git a/lib-crypt/crypt-gpgme.c b/lib-crypt/crypt-gpgme.c index 72dd3ab..445dc77 100644 --- a/lib-crypt/crypt-gpgme.c +++ b/lib-crypt/crypt-gpgme.c @@ -1631,7 +1631,7 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, return 0; } - if ((tfp = fdopen (tempfd, "r")) == NULL) { + if ((tfp = fopen(tempfile, "r")) == NULL) { unlink (tempfile); return 0; } diff --git a/lib-crypt/pgp.c b/lib-crypt/pgp.c index 3dd37d5..297eb73 100644 --- a/lib-crypt/pgp.c +++ b/lib-crypt/pgp.c @@ -467,14 +467,13 @@ static int pgp_check_traditional_one_body (FILE * fp, BODY * b, return 0; tempfd = m_tempfd(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); - if (mutt_decode_save_attachment (fp, b, tempfd, 0) != 0) { unlink (tempfile); return 0; } - if ((tfp = fdopen (tempfd, "r")) == NULL) { - unlink (tempfile); + if (!(tfp = fopen(tempfile, "r"))) { + unlink(tempfile); return 0; }