-
Bug
-
Resolution: Unresolved
-
P3
-
18, 19
ADDITIONAL SYSTEM INFORMATION :
OS Name: Microsoft Windows Server 2016 Standard
OS Version: 10.0.14393 N/A Build 14393
openjdk 18.0.1.1 2022-04-22
OpenJDK Runtime Environment (build 18.0.1.1+2-6)
OpenJDK 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
WindowsUserDefinedFileAttributeView fails to read or write user-defined file attributes (otherwise known as alternate data streams) with names containing control characters. According to Microsoft's documentation on file naming in Windows, alternate data streams are allowed to have control characters in their names [1]. One use case for including control characters in the names of alternate data streams is described in Microsoft's documentation on Object Linking and Embedding (OLE) Property Set Data Structures [2]. Section 2.23 of the OLE documentation states that property set stream names must start with the \005 character.
This appears to be a regression in JDK 18 caused by a change to WindowsUserDefinedFileAttributeView.java. The change modifies WindowsUserDefinedFileAttributeView::join to pass the file attribute name to WindowsPath::parse [3]. This leads to WindowsPathParser::normalize throwing an InvalidPathException because it considers control characters to be illegal, even though they are valid in file attribute names.
[1] https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
[2] https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-OLEPS/%5bMS-OLEPS%5d.pdf
[3] https://github.com/openjdk/jdk18/commit/684edbb4c884cbc3e05118e4bc9808b5d5b71a74
REGRESSION : Last worked in version 17
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached test case using JDK 18 on a Windows system.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception.
ACTUAL -
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <?> at index 0: ?SummaryInformation
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsUserDefinedFileAttributeView.join(WindowsUserDefinedFileAttributeView.java:59)
at java.base/sun.nio.fs.WindowsUserDefinedFileAttributeView.write(WindowsUserDefinedFileAttributeView.java:213)
at AdsTest.main(AdsTest.java:12)
---------- BEGIN SOURCE ----------
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.UserDefinedFileAttributeView;
public class AdsTest {
public static void main(String[] args) throws Exception {
Path path = Paths.get("Z:\\ads_test");
Files.writeString(path, "alternate data stream test");
UserDefinedFileAttributeView userView = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
userView.write("\u0005SummaryInformation", StandardCharsets.UTF_8.encode("DONTCARE"));
}
}
---------- END SOURCE ----------
FREQUENCY : always
OS Name: Microsoft Windows Server 2016 Standard
OS Version: 10.0.14393 N/A Build 14393
openjdk 18.0.1.1 2022-04-22
OpenJDK Runtime Environment (build 18.0.1.1+2-6)
OpenJDK 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
WindowsUserDefinedFileAttributeView fails to read or write user-defined file attributes (otherwise known as alternate data streams) with names containing control characters. According to Microsoft's documentation on file naming in Windows, alternate data streams are allowed to have control characters in their names [1]. One use case for including control characters in the names of alternate data streams is described in Microsoft's documentation on Object Linking and Embedding (OLE) Property Set Data Structures [2]. Section 2.23 of the OLE documentation states that property set stream names must start with the \005 character.
This appears to be a regression in JDK 18 caused by a change to WindowsUserDefinedFileAttributeView.java. The change modifies WindowsUserDefinedFileAttributeView::join to pass the file attribute name to WindowsPath::parse [3]. This leads to WindowsPathParser::normalize throwing an InvalidPathException because it considers control characters to be illegal, even though they are valid in file attribute names.
[1] https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
[2] https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-OLEPS/%5bMS-OLEPS%5d.pdf
[3] https://github.com/openjdk/jdk18/commit/684edbb4c884cbc3e05118e4bc9808b5d5b71a74
REGRESSION : Last worked in version 17
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached test case using JDK 18 on a Windows system.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No exception.
ACTUAL -
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <?> at index 0: ?SummaryInformation
at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
at java.base/sun.nio.fs.WindowsUserDefinedFileAttributeView.join(WindowsUserDefinedFileAttributeView.java:59)
at java.base/sun.nio.fs.WindowsUserDefinedFileAttributeView.write(WindowsUserDefinedFileAttributeView.java:213)
at AdsTest.main(AdsTest.java:12)
---------- BEGIN SOURCE ----------
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.UserDefinedFileAttributeView;
public class AdsTest {
public static void main(String[] args) throws Exception {
Path path = Paths.get("Z:\\ads_test");
Files.writeString(path, "alternate data stream test");
UserDefinedFileAttributeView userView = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class);
userView.write("\u0005SummaryInformation", StandardCharsets.UTF_8.encode("DONTCARE"));
}
}
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-8273922 (fs) UserDefinedFileAttributeView doesn't handle file names that are just under the MAX_PATH limit (win)
-
- Closed
-