Wireguard iOS crashes after upgrading to XCode 14

Andrej Mihajlov and at mullvad.net
Thu Sep 22 08:31:52 UTC 2022


Hi,

I think we have a bug. If I am right, basically in both IPv4 and IPv6 extensions, withMemoryRebound takes capacity which is actually a number of instances of a given type (sockaddr_ variant) and not the byte size of a struct. 

Could you please patch your WireGuardKit with the following commit and see if it helps? 

https://git.zx2c4.com/wireguard-apple/commit/?h=am/fix-addrinfo-crash

Best regards,
Andrey Mikhaylov

> On 13 Sep 2022, at 14:41, Houman <houmie at gmail.com> wrote:
> 
> 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,



More information about the WireGuard mailing list