From 3a6a6030bfdbf38c578b114920e20dd5ccfacde4 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 25 Oct 2017 10:59:58 +0900 Subject: [PATCH] Don't crash if password BCrypt formatted --- .../com/nutomic/syncthingandroid/util/ConfigXml.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java index b0581298..4cdc5540 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java @@ -142,9 +142,14 @@ public class ConfigXml { gui.appendChild(password); } String apikey = getApiKey(); - boolean passwordOk; String pw = password.getTextContent(); - passwordOk = !TextUtils.isEmpty(pw) && BCrypt.checkpw(apikey, pw); + boolean passwordOk; + try { + passwordOk = !TextUtils.isEmpty(pw) && BCrypt.checkpw(apikey, pw); + } catch (IllegalArgumentException e) { + Log.w(TAG, "Malformed password", e); + passwordOk = false; + } if (!passwordOk) { Log.i(TAG, "Updating password"); password.setTextContent(BCrypt.hashpw(apikey, BCrypt.gensalt(4)));