Prechádzať zdrojové kódy

fixed change pw function leaving invalid JSON file if length gets shorter due to different encoding or pretty printing etc

Sebastian Stenzel 8 rokov pred
rodič
commit
47133c6f31

+ 1 - 0
main/filesystem-crypto/src/main/java/org/cryptomator/filesystem/crypto/Masterkeys.java

@@ -103,6 +103,7 @@ class Masterkeys {
 
 	private static void writeMasterKey(File file, Cryptor cryptor, CharSequence passphrase) throws UncheckedIOException {
 		try (WritableFile writable = file.openWritable()) {
+			writable.truncate();
 			final byte[] fileContents = cryptor.writeKeysToMasterkeyFile(passphrase);
 			writable.write(ByteBuffer.wrap(fileContents));
 		}