From: Jason A. Donenfeld Date: Wed, 23 Dec 2020 13:06:26 +0000 (+0100) Subject: Kit: do not crash on [abcd::] with missing port X-Git-Tag: 1.0.12-22~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b67acaccff1b587717c1fc444179307da4919c12;p=thirdparty%2Fwireguard-apple.git Kit: do not crash on [abcd::] with missing port Signed-off-by: Jason A. Donenfeld --- 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])