Pārlūkot izejas kodu

Interface: Correctly handle setting a null or empty key

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
master
Samuel Holland pirms 7 gadiem
vecāks
revīzija
529e320e3f
1 mainītis faili ar 8 papildinājumiem un 4 dzēšanām
  1. +8
    -4
      app/src/main/java/com/wireguard/config/Interface.java

+ 8
- 4
app/src/main/java/com/wireguard/config/Interface.java Parādīt failu

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


Notiek ielāde…
Atcelt
Saglabāt