aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2014-04-12 14:54:27 -0700
committerPaul Eggert2014-04-12 14:54:27 -0700
commita9108bf189e6cccfe568348ec604b9eecd17a125 (patch)
tree9ea864fe8764d383a6a6a74719d15fb049415efc /src
parent175a3a5144ab17bc8c854cd0cc6c1771d79a9f9c (diff)
downloademacs-a9108bf189e6cccfe568348ec604b9eecd17a125.tar.gz
emacs-a9108bf189e6cccfe568348ec604b9eecd17a125.zip
* keyboard.c (Fopen_dribble_file): Avoid some races.
Fixes: debbugs:17187
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/keyboard.c12
2 files changed, 7 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index cb17738d139..2d7307412b2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
12014-04-12 Paul Eggert <eggert@cs.ucla.edu>
2
3 * keyboard.c (Fopen_dribble_file): Avoid some races. (Bug#17187)
4
12014-04-12 Eli Zaretskii <eliz@gnu.org> 52014-04-12 Eli Zaretskii <eliz@gnu.org>
2 6
3 * xdisp.c (move_it_by_lines): If a large portion of buffer text is 7 * xdisp.c (move_it_by_lines): If a large portion of buffer text is
diff --git a/src/keyboard.c b/src/keyboard.c
index f74ba0ee581..a66054f153f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10088,15 +10088,9 @@ This may include sensitive information such as passwords. */)
10088 { 10088 {
10089 int fd; 10089 int fd;
10090 file = Fexpand_file_name (file, Qnil); 10090 file = Fexpand_file_name (file, Qnil);
10091 /* This isn't robust, since eg file could be created after we 10091 fd = emacs_open (SSDATA (file), O_WRONLY | O_CREAT | O_EXCL, 0600);
10092 check whether it exists but before emacs_open. 10092 if (fd < 0 && errno == EEXIST && unlink (SSDATA (file)) == 0)
10093 Feel free to improve it, but this is not critical. (Bug#17187) */ 10093 fd = emacs_open (SSDATA (file), O_WRONLY | O_CREAT | O_EXCL, 0600);
10094 if (! NILP (Ffile_exists_p (file)))
10095 {
10096 if (chmod (SSDATA (file), 0600) < 0)
10097 report_file_error ("Doing chmod", file);
10098 }
10099 fd = emacs_open (SSDATA (file), O_WRONLY | O_CREAT | O_TRUNC, 0600);
10100 dribble = fd < 0 ? 0 : fdopen (fd, "w"); 10094 dribble = fd < 0 ? 0 : fdopen (fd, "w");
10101 if (dribble == 0) 10095 if (dribble == 0)
10102 report_file_error ("Opening dribble", file); 10096 report_file_error ("Opening dribble", file);