X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=attach.c;h=102329da54f385e689b1b1981ca8eaaab4f4bf4c;hp=2179a499b4f2830345735db49c3e1c500422ed0b;hb=fdf0986350bf8b49a817aaf53526904f8ed5b8de;hpb=1d7238dc43311c4545883dc1151bf5b142d88c0b diff --git a/attach.c b/attach.c index 2179a49..102329d 100644 --- a/attach.c +++ b/attach.c @@ -17,6 +17,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +#if HAVE_CONFIG_H +# include "config.h" +#endif + #include "mutt.h" #include "mutt_menu.h" #include "mutt_curses.h" @@ -108,7 +112,8 @@ int mutt_compose_attachment (BODY *a) if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) != M_YES) goto bailout; } - unlink_newfile = 1; + else + unlink_newfile = 1; } else strfcpy(newfile, a->filename, sizeof(newfile)); @@ -173,7 +178,11 @@ int mutt_compose_attachment (BODY *a) fclose (fp); fclose (tfp); mutt_unlink (a->filename); - mutt_rename_file (tempfile, a->filename); + if (mutt_rename_file (tempfile, a->filename) != 0) + { + mutt_perror _("Failure to rename file."); + goto bailout; + } mutt_free_body (&b); } @@ -235,7 +244,8 @@ int mutt_edit_attachment (BODY *a) if (mutt_yesorno (_("Can't match nametemplate, continue?"), M_YES) != M_YES) goto bailout; } - unlink_newfile = 1; + else + unlink_newfile = 1; } else strfcpy(newfile, a->filename, sizeof(newfile)); @@ -607,6 +617,7 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr, rc = mutt_do_pager (descrip, pagerfile, M_PAGER_ATTACHMENT | (is_message ? M_PAGER_MESSAGE : 0), &info); + *pagerfile = '\0'; } else rc = 0; @@ -722,8 +733,11 @@ mutt_save_attachment_open (char *path, int flags) { if (flags == M_SAVE_APPEND) return fopen (path, "a"); + /* be sure not to change the following fopen to safe_fopen + * as safe_fopen returns w/ an error if path exists + */ if (flags == M_SAVE_OVERWRITE) - return safe_fopen (path, "w"); /* __FOPEN_CHECKED__ */ + return fopen (path, "w"); /* __FOPEN_CHECKED__ */ return safe_fopen (path, "w"); }