diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-12-23 14:06:26 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2020-12-23 14:06:26 +0100 |
commit | b67acaccff1b587717c1fc444179307da4919c12 (patch) | |
tree | 4369e470d05e11cb23d33fedbb1055b1c8181842 | |
parent | Kit: Go: bump module and simplify API (diff) | |
download | wireguard-apple-b67acaccff1b587717c1fc444179307da4919c12.tar.xz wireguard-apple-b67acaccff1b587717c1fc444179307da4919c12.zip |
Kit: do not crash on [abcd::] with missing port
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | Sources/WireGuardKit/Endpoint.swift | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Sources/WireGuardKit/Endpoint.swift b/Sources/WireGuardKit/Endpoint.swift index d86290f..8454d87 100644 --- a/Sources/WireGuardKit/Endpoint.swift +++ b/Sources/WireGuardKit/Endpoint.swift @@ -52,6 +52,7 @@ extension Endpoint { let startOfHost = string.index(after: string.startIndex) guard let endOfHost = string.dropFirst().firstIndex(of: "]") else { return nil } let afterEndOfHost = string.index(after: endOfHost) + if afterEndOfHost == string.endIndex { return nil } guard string[afterEndOfHost] == ":" else { return nil } startOfPort = string.index(after: afterEndOfHost) hostString = String(string[startOfHost ..< endOfHost]) |