From b2c9b3500cd2aae8b6d5eab5863b0fb72dedbefd Mon Sep 17 00:00:00 2001
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
Date: Mon, 10 Dec 2018 15:54:38 +0100
Subject: Do not allow for an empty port in endpoint

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 app/src/main/java/com/wireguard/config/InetEndpoint.java | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'app/src/main/java/com/wireguard/config')

diff --git a/app/src/main/java/com/wireguard/config/InetEndpoint.java b/app/src/main/java/com/wireguard/config/InetEndpoint.java
index 06d0ca80..962d97c6 100644
--- a/app/src/main/java/com/wireguard/config/InetEndpoint.java
+++ b/app/src/main/java/com/wireguard/config/InetEndpoint.java
@@ -51,6 +51,8 @@ public final class InetEndpoint {
         } catch (final URISyntaxException e) {
             throw new IllegalArgumentException(e);
         }
+        if (uri.getPort() < 0)
+            throw new IllegalArgumentException("An endpoint must specify a port (e.g. 51820)");
         try {
             InetAddresses.parse(uri.getHost());
             // Parsing ths host as a numeric address worked, so we don't need to do DNS lookups.
-- 
cgit v1.2.3