diff options
| author | Federico Tedin | 2021-09-15 00:15:16 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2021-09-18 09:36:26 +0300 |
| commit | 4e21c5f451a18f96172e63dbe8a3ceef780758bb (patch) | |
| tree | eb8e8408ac1db13a0892eb20818189e3f3f086fd /src/fileio.c | |
| parent | 62e870691d2192e7848e047734556dec21797a7b (diff) | |
| download | emacs-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/fileio.c')
| -rw-r--r-- | src/fileio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c index 0db8ed793b3..3c13d3fe416 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -945,6 +945,7 @@ the root directory. */) | |||
| 945 | USE_SAFE_ALLOCA; | 945 | USE_SAFE_ALLOCA; |
| 946 | 946 | ||
| 947 | CHECK_STRING (name); | 947 | CHECK_STRING (name); |
| 948 | CHECK_STRING_NULL_BYTES (name); | ||
| 948 | 949 | ||
| 949 | /* If the file name has special constructs in it, | 950 | /* If the file name has special constructs in it, |
| 950 | call the corresponding file name handler. */ | 951 | call the corresponding file name handler. */ |
| @@ -993,7 +994,10 @@ the root directory. */) | |||
| 993 | if (STRINGP (dir)) | 994 | if (STRINGP (dir)) |
| 994 | { | 995 | { |
| 995 | if (file_name_absolute_no_tilde_p (dir)) | 996 | if (file_name_absolute_no_tilde_p (dir)) |
| 996 | default_directory = dir; | 997 | { |
| 998 | CHECK_STRING_NULL_BYTES (dir); | ||
| 999 | default_directory = dir; | ||
| 1000 | } | ||
| 997 | else | 1001 | else |
| 998 | { | 1002 | { |
| 999 | Lisp_Object absdir | 1003 | Lisp_Object absdir |