cryptomator / cryptofs

Java Filesystem Provider with integrated encryption
GNU Affero General Public License v3.0
93 stars 35 forks source link

Invoking file system methods with root path throws NullPointerException #132

Closed infeo closed 2 years ago

infeo commented 2 years ago

The JDK filesystem API takes an arbitrary Path as an argument. Hence, also for the filesystem root the following is a valid method call:

Path root = fs.getPath("/");
Files.createDirectory(root);

Although the above will likely throw an exception, it should be an IOException. Currently, a NullPointerException is thrown, caused by https://github.com/cryptomator/cryptofs/blob/59a8ec29d9a834f10a36a53202720b72020b5475/src/main/java/org/cryptomator/cryptofs/CryptoFileSystemImpl.java#L630-L635.

We need some null-check for Path::getFileName. Additionally, we should check which other methods choke on the root path.