From 46a4060814118f4952add8179bd095ce8f65fc78 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Mon, 19 Aug 2019 16:14:11 +0200 Subject: [PATCH] fixed unlock --- .../cryptomator/ui/unlock/UnlockController.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockController.java b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockController.java index e43378a3b..3212bc57e 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockController.java @@ -140,7 +140,7 @@ public class UnlockController implements FxController { private void loadStoredPassword() { assert keychainAccess.isPresent(); - char[] storedPw = new char[0]; + char[] storedPw = null; try { storedPw = keychainAccess.get().loadPassphrase(vault.getId()); if (storedPw != null) { @@ -151,19 +151,23 @@ public class UnlockController implements FxController { } catch (KeychainAccessException e) { LOG.error("Failed to load entry from system keychain.", e); } finally { - Arrays.fill(storedPw, ' '); + if (storedPw != null) { + Arrays.fill(storedPw, ' '); + } } } private boolean hasStoredPassword() { - char[] storedPw = new char[0]; + char[] storedPw = null; try { storedPw = keychainAccess.get().loadPassphrase(vault.getId()); - return storedPw.length != 0; + return storedPw != null; } catch (KeychainAccessException e) { return false; } finally { - Arrays.fill(storedPw, ' '); + if (storedPw != null) { + Arrays.fill(storedPw, ' '); + } } }