From 99973a4b08f955bbd9af01873120e8c3eeb84e1e Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Tue, 8 Aug 2017 05:54:35 -0500 Subject: [PATCH] Profile: Add helper to check name validity Signed-off-by: Jason A. Donenfeld --- app/src/main/java/com/wireguard/config/Profile.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/java/com/wireguard/config/Profile.java b/app/src/main/java/com/wireguard/config/Profile.java index ab4d645b..e04cab3e 100644 --- a/app/src/main/java/com/wireguard/config/Profile.java +++ b/app/src/main/java/com/wireguard/config/Profile.java @@ -20,6 +20,11 @@ import java.nio.charset.StandardCharsets; */ public class Profile extends BaseObservable implements Copyable, Observable { + public static boolean isNameValid(String name) { + final int IFNAMSIZ = 16; + return !name.contains(" ") && name.getBytes(StandardCharsets.UTF_8).length <= IFNAMSIZ; + } + private final Interface iface = new Interface(); private boolean isConnected; private String name;