aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorFederico Tedin2021-09-15 00:15:16 +0200
committerEli Zaretskii2021-09-18 09:36:26 +0300
commit4e21c5f451a18f96172e63dbe8a3ceef780758bb (patch)
treeeb8e8408ac1db13a0892eb20818189e3f3f086fd /src/coding.c
parent62e870691d2192e7848e047734556dec21797a7b (diff)
downloademacs-4e21c5f451a18f96172e63dbe8a3ceef780758bb.tar.gz
emacs-4e21c5f451a18f96172e63dbe8a3ceef780758bb.zip
Check for null bytes in filenames in 'expand-file-name' (bug#49723)
* src/fileio.c (expand-file-name): Check for null bytes for both NAME and DEFAULT-DIRECTORY arguments. Also check for null bytes in buffer-local default-directory, assuming it is used. * src/coding.c (encode_file_name): Use CHECK_STRING_NULL_BYTES. * src/lisp.h (CHECK_STRING_NULL_BYTES): Add function for checking for null bytes in Lisp strings. * test/src/fileio-tests.el (fileio-test--expand-file-name-null-bytes): Add test for new changes to expand-file-name. * etc/NEWS: Announce changes.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/coding.c b/src/coding.c
index d027c7d5399..7030a53869a 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -10430,8 +10430,7 @@ encode_file_name (Lisp_Object fname)
10430 cause subtle bugs because the system would silently use a 10430 cause subtle bugs because the system would silently use a
10431 different filename than expected. Perform this check after 10431 different filename than expected. Perform this check after
10432 encoding to not miss NUL bytes introduced through encoding. */ 10432 encoding to not miss NUL bytes introduced through encoding. */
10433 CHECK_TYPE (memchr (SSDATA (encoded), '\0', SBYTES (encoded)) == NULL, 10433 CHECK_STRING_NULL_BYTES (encoded);
10434 Qfilenamep, fname);
10435 return encoded; 10434 return encoded;
10436} 10435}
10437 10436