summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-09 02:51:54 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-09 02:51:54 -0500
commita489eaf21357b9b3a7f3a06b27cf884a066c177f (patch)
treeb6d9dc9ea11093730d932220978c7ee547ae25d6 /app/src/main/java/com/wireguard
parentb7e80a93280cf6837443268c3bd3692cc009f9fb (diff)
Interface: Correctly handle setting a null or empty key
Diffstat (limited to 'app/src/main/java/com/wireguard')
-rw-r--r--app/src/main/java/com/wireguard/config/Interface.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/app/src/main/java/com/wireguard/config/Interface.java b/app/src/main/java/com/wireguard/config/Interface.java
index d583f37b..6116a4a7 100644
--- a/app/src/main/java/com/wireguard/config/Interface.java
+++ b/app/src/main/java/com/wireguard/config/Interface.java
@@ -90,10 +90,14 @@ public class Interface extends BaseObservable implements Observable {
}
public void setPrivateKey(String privateKey) {
- // Avoid exceptions from Keypair while the user is typing.
- if (privateKey.length() != KeyEncoding.KEY_LENGTH_BASE64)
- return;
- keypair = new Keypair(privateKey);
+ if (privateKey != null && !privateKey.isEmpty()) {
+ // Avoid exceptions from Keypair while the user is typing.
+ if (privateKey.length() != KeyEncoding.KEY_LENGTH_BASE64)
+ return;
+ keypair = new Keypair(privateKey);
+ } else {
+ keypair = null;
+ }
notifyPropertyChanged(BR.privateKey);
notifyPropertyChanged(BR.publicKey);
}