summaryrefslogtreecommitdiffstats
path: root/attach.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-02-28 08:05:54 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-02-28 08:05:54 +0000
commitec42e01f8fe4623178a747c551dcfb3ebc5d397c (patch)
tree54045806fba79f5c6af27c909be7a01d4c38fd0c /attach.c
parentae40aac542aaa9c417ae8588433492520bda20a2 (diff)
Fix a $TMPDIR race condition.
Diffstat (limited to 'attach.c')
-rw-r--r--attach.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/attach.c b/attach.c
index 81b9c561..f4a0d3b0 100644
--- a/attach.c
+++ b/attach.c
@@ -712,9 +712,11 @@ int mutt_save_attachment (FILE *fp, BODY *m, char *path, int flags, HEADER *hdr)
memset (&s, 0, sizeof (s));
if (flags == M_SAVE_APPEND)
- s.fpout = safe_fopen (path, "a");
- else
+ s.fpout = fopen (path, "a");
+ else if (flags == M_SAVE_OVERWRITE)
s.fpout = fopen (path, "w");
+ else
+ s.fpout = safe_fopen (path, "w");
if (s.fpout == NULL)
{
mutt_perror ("fopen");
@@ -776,9 +778,12 @@ int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path,
s.flags = (displaying ? M_DISPLAY : 0);
if (flags == M_SAVE_APPEND)
- s.fpout = safe_fopen (path, "a");
- else
+ s.fpout = fopen (path, "a");
+ else if (flags == M_SAVE_OVERWRITE)
s.fpout = fopen (path, "w");
+ else
+ s.fpout = safe_fopen (path, "w");
+
if (s.fpout == NULL)
{
perror ("fopen");