Avoid crashes on MS-Windows due to invalid UNC file names
* src/w32.c (parse_root): Avoid crashes due to invalid (too short) UNC names, such as "\\". (Bug#70914) * test/src/fileio-tests.el (fileio-tests-invalid-UNC): New test.
This commit is contained in:
parent
ccf8dba44a
commit
350ae75f5c
2 changed files with 7 additions and 1 deletions
|
@ -2572,7 +2572,7 @@ parse_root (const char * name, const char ** pPath)
|
||||||
name += 2;
|
name += 2;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (IS_DIRECTORY_SEP (*name) && --slashes == 0)
|
if (!*name || (IS_DIRECTORY_SEP (*name) && --slashes == 0))
|
||||||
break;
|
break;
|
||||||
name++;
|
name++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,4 +218,10 @@ Also check that an encoding error can appear in a symlink."
|
||||||
(should (equal (expand-file-name file nil) file))
|
(should (equal (expand-file-name file nil) file))
|
||||||
(file-name-case-insensitive-p file)))
|
(file-name-case-insensitive-p file)))
|
||||||
|
|
||||||
|
(ert-deftest fileio-tests-invalid-UNC ()
|
||||||
|
(skip-unless (eq system-type 'windows-nt))
|
||||||
|
;; These should not crash, see bug#70914.
|
||||||
|
(should-not (file-exists-p "//"))
|
||||||
|
(should (file-attributes "//")))
|
||||||
|
|
||||||
;;; fileio-tests.el ends here
|
;;; fileio-tests.el ends here
|
||||||
|
|
Loading…
Add table
Reference in a new issue