mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 11:21:29 +00:00
Don't crash if password BCrypt formatted
This commit is contained in:
parent
3409578995
commit
3a6a6030bf
1 changed files with 7 additions and 2 deletions
|
@ -142,9 +142,14 @@ public class ConfigXml {
|
||||||
gui.appendChild(password);
|
gui.appendChild(password);
|
||||||
}
|
}
|
||||||
String apikey = getApiKey();
|
String apikey = getApiKey();
|
||||||
boolean passwordOk;
|
|
||||||
String pw = password.getTextContent();
|
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) {
|
if (!passwordOk) {
|
||||||
Log.i(TAG, "Updating password");
|
Log.i(TAG, "Updating password");
|
||||||
password.setTextContent(BCrypt.hashpw(apikey, BCrypt.gensalt(4)));
|
password.setTextContent(BCrypt.hashpw(apikey, BCrypt.gensalt(4)));
|
||||||
|
|
Loading…
Reference in a new issue