8273922: (fs) UserDefinedFileAttributeView doesn't handle file names that are just under the MAX_PATH limit (win)

Reviewed-by: alanb
This commit is contained in:
Brian Burkhalter 2021-11-03 16:55:23 +00:00
parent 7115892f96
commit 684edbb4c8
2 changed files with 70 additions and 15 deletions

View file

@ -51,8 +51,19 @@ class WindowsUserDefinedFileAttributeView
throw new NullPointerException("'name' is null");
return file + ":" + name;
}
private String join(WindowsPath file, String name) throws WindowsException {
return join(file.getPathForWin32Calls(), name);
if (name == null)
throw new NullPointerException("'name' is null");
WindowsFileSystem wfs = file.getFileSystem();
WindowsPath namePath = WindowsPath.parse(wfs, name);
if (namePath.getRoot() != null)
throw new IllegalArgumentException("'name' has a root component");
if (namePath.getParent() != null)
throw new IllegalArgumentException("'name' has more than one element");
String path = join(file.getPathForWin32Calls(), name);
WindowsPath wp = WindowsPath.createFromNormalizedPath(wfs, path);
return wp.getPathForWin32Calls();
}
private final WindowsPath file;