My existing Wireguard iOS implementation stopped working after
upgrading to Xcode 14 today.
When trying to connect to servers that support only IPv4, then it's
fine. But if the server supports both IPv6 and IPv4 then the tunnel
crashes:

This IPv6 extension in
wireguard-apple/Sources/WireGuardKit/IPAddress+AddrInfo.swift crashes
with a Fatal Error at addrInfo.ai_addr.withMemoryRebound()

The whole extension below:

extension IPv6Address {
    init?(addrInfo: addrinfo) {
        guard addrInfo.ai_family == AF_INET6 else { return nil }

        let addressData = addrInfo.ai_addr.withMemoryRebound(to:
sockaddr_in6.self, capacity: MemoryLayout<sockaddr_in6>.size) { ptr ->
Data in
            return Data(bytes: &ptr.pointee.sin6_addr, count:
MemoryLayout<in6_addr>.size)
        }
        self.init(addressData)
    }
}

Has anyone else experienced this problem?

Thanks,

Reply via email to