1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 03:11:30 +00:00

Don't crash if password BCrypt formatted

This commit is contained in:
Felix Ableitner 2017-10-25 10:59:58 +09:00
parent 3409578995
commit 3a6a6030bf

View file

@ -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)));