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 /test/src | |
| 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 'test/src')
| -rw-r--r-- | test/src/fileio-tests.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index f4d123b4261..438ebebb769 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el | |||
| @@ -136,6 +136,15 @@ Also check that an encoding error can appear in a symlink." | |||
| 136 | (should (and (file-name-absolute-p name) | 136 | (should (and (file-name-absolute-p name) |
| 137 | (not (eq (aref name 0) ?~)))))) | 137 | (not (eq (aref name 0) ?~)))))) |
| 138 | 138 | ||
| 139 | (ert-deftest fileio-test--expand-file-name-null-bytes () | ||
| 140 | "Test that expand-file-name checks for null bytes in filenames." | ||
| 141 | (should-error (expand-file-name (concat "file" (char-to-string ?\0) ".txt")) | ||
| 142 | :type 'wrong-type-argument) | ||
| 143 | (should-error (expand-file-name "file.txt" (concat "dir" (char-to-string ?\0))) | ||
| 144 | :type 'wrong-type-argument) | ||
| 145 | (let ((default-directory (concat "dir" (char-to-string ?\0)))) | ||
| 146 | (should-error (expand-file-name "file.txt") :type 'wrong-type-argument))) | ||
| 147 | |||
| 139 | (ert-deftest fileio-tests--file-name-absolute-p () | 148 | (ert-deftest fileio-tests--file-name-absolute-p () |
| 140 | "Test file-name-absolute-p." | 149 | "Test file-name-absolute-p." |
| 141 | (dolist (suffix '("" "/" "//" "/foo" "/foo/" "/foo//" "/foo/bar")) | 150 | (dolist (suffix '("" "/" "//" "/foo" "/foo/" "/foo//" "/foo/bar")) |