summaryrefslogtreecommitdiff
path: root/test/src/fileio-tests.el
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2020-12-23 12:00:46 +0100
committerPhilipp Stephani <phst@google.com>2020-12-23 12:00:46 +0100
commit3cbd4169d6dd370b4fa8180fc2adfbf426f57837 (patch)
tree11b24ad133c4f24f9e8d8798f4fb482944de15ab /test/src/fileio-tests.el
parent3edc4fd53ff9e1355da2371400aac4d5897ca190 (diff)
downloademacs-3cbd4169d6dd370b4fa8180fc2adfbf426f57837.tar.gz
Reject filenames containing NUL bytes.
Such filenames are dangerous, as Emacs would silently only use the part up to the first NUL byte. Reject them explicitly instead. * src/coding.c (encode_file_name_1): New helper function. (encode_file_name): Check that encoded filename doesn't contain a NUL byte. (syms_of_coding): Define 'filenamep' symbol. * test/src/fileio-tests.el (fileio-tests/null-character): New unit test. * etc/NEWS: Document change.
Diffstat (limited to 'test/src/fileio-tests.el')
-rw-r--r--test/src/fileio-tests.el6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el
index ed381d151ee..8d46abf342a 100644
--- a/test/src/fileio-tests.el
+++ b/test/src/fileio-tests.el
@@ -155,3 +155,9 @@ Also check that an encoding error can appear in a symlink."
(write-region "hello\n" nil f nil 'silent)
(should-error (insert-file-contents f) :type 'circular-list)
(delete-file f)))
+
+(ert-deftest fileio-tests/null-character ()
+ (should-error (file-exists-p "/foo\0bar")
+ :type 'wrong-type-argument))
+
+;;; fileio-tests.el ends here