cryptomator / cryptofs

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

Symbolic links have size -1 #74

Closed infeo closed 4 years ago

infeo commented 4 years ago

The CryptoBasicFileAttributes class is a wrapper for BasicFileAttributes to show basic properties of the encrypted files.

During construction the type of the ciphertext file is important to determine the size of the requested cleartext file: https://github.com/cryptomator/cryptofs/blob/4ec6f2f33cb818229e6900fe7dc2e5dfac331591/src/main/java/org/cryptomator/cryptofs/attr/CryptoBasicFileAttributes.java#L38-L52

As one can see in the code, if the file cleartext file is supposed to be a symbolic link, the file size is set to -1.

But since symbolic links are also files, they do have a strict positive size (see for example here or there). This leads to unwanted behaviour like described in https://github.com/cryptomator/cryptomator/issues/1092#issuecomment-611621634.

overheadhunter commented 4 years ago

We'll return delegate.size() instead.