summarylogtreecommitdiffstats
path: root/528233-readonly-open.patch
blob: 55ea401306ce375bd0ce09a52f8f4ca247115a51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From: Antonio Radici <antonio@debian.org>
Date: Thu, 27 Feb 2014 17:07:35 +0100
Subject: 528233-readonly-open

Open attachments as read-only so the editor won't be able to modify it;
otherwise the user can believe that he/she can edit it and risk to lose
his/her work (see upstream bug http://bugs.mutt.org/3261)

Debian bugs: #528233, updated in #572203

Gbp-Pq: Topic upstream
---
 attach.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/attach.c b/attach.c
index 0efeb79..c5f47d9 100644
--- a/attach.c
+++ b/attach.c
@@ -415,6 +415,7 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
       FREE (&fname);
       if (mutt_save_attachment (fp, a, tempfile, 0, NULL) == -1)
 	goto return_error;
+      chmod (tempfile, 0400);
     }
 
     use_pipe = rfc1524_expand_command (a, tempfile, type,
@@ -587,7 +588,11 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
   if (entry)
     rfc1524_free_entry (&entry);
   if (fp && tempfile[0])
+  {
+    /* Restore write permission so mutt_unlink can open the file for writing */
+    chmod(tempfile, 0600);
     mutt_unlink (tempfile);
+  }
   else if (unlink_tempfile)
     unlink(tempfile);