From ced78c5a65b64b0e520b03cd3a987374ea4ca7d2 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 13 Apr 2014 13:45:46 +0300 Subject: [PATCH] Fix open-dribble-file's treatment of non-ASCII file names. src/keyboard.c (Fopen_dribble_file): Encode the dribble file-name before passing it to system APIs. --- src/ChangeLog | 3 +++ src/keyboard.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 2deeb61b95c..d885863d73c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2014-04-13 Eli Zaretskii + * keyboard.c (Fopen_dribble_file): Encode the dribble file-name + before passing it to system APIs. + * puresize.h (BASE_PURESIZE): Bump by 1K. (Bug#17255) 2014-04-13 Stefan Monnier diff --git a/src/keyboard.c b/src/keyboard.c index a66054f153f..1f4b23d9905 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -10087,10 +10087,13 @@ This may include sensitive information such as passwords. */) if (!NILP (file)) { int fd; + Lisp_Object encfile; + file = Fexpand_file_name (file, Qnil); - fd = emacs_open (SSDATA (file), O_WRONLY | O_CREAT | O_EXCL, 0600); - if (fd < 0 && errno == EEXIST && unlink (SSDATA (file)) == 0) - fd = emacs_open (SSDATA (file), O_WRONLY | O_CREAT | O_EXCL, 0600); + encfile = ENCODE_FILE (file); + fd = emacs_open (SSDATA (encfile), O_WRONLY | O_CREAT | O_EXCL, 0600); + if (fd < 0 && errno == EEXIST && unlink (SSDATA (encfile)) == 0) + fd = emacs_open (SSDATA (encfile), O_WRONLY | O_CREAT | O_EXCL, 0600); dribble = fd < 0 ? 0 : fdopen (fd, "w"); if (dribble == 0) report_file_error ("Opening dribble", file); -- 2.39.5