SLikeSoft / SLikeNet

SLikeNetâ„¢ is an Open Source/Free Software cross-platform network engine written in C++ and specifially designed for games (and applications which have comparable requirements on a network engine like games) building upon the discontinued RakNet network engine which had more than 13 years of active development.
https://www.slikenet.com/
Other
395 stars 62 forks source link

Wrong output value size for getnameinfo #45

Open pw-fomin opened 5 years ago

pw-fomin commented 5 years ago

While building RakNet 4.081 i found a bug and looks like it still presents in SLikeNet. Bug can be reproduced if call this code:

        char host[65];
        RakNet::RakNetSocket2::DomainNameToIP( remoteIp, host );

with flag RAKNET_SUPPORT_IPV6 set to 1.

Call goes to method DomainNameToIP_Berkley_IPV4And6. In this method getaddrinfo called. On my machine first goes addrinfo from getaddrinfo with AF_INET6 family, so we goes to line 66:

And bug is here: we pass output parameter ip with size of 1 instead of sizeof(ip) to getnameinfo, so the correct code will be: getnameinfo((struct sockaddr *)ipv6, sizeof(struct sockaddr_in6), ip, sizeof(ip), NULL, 0, NI_NUMERICHOST);

getnameinfo on MSDN - https://docs.microsoft.com/en-us/windows/desktop/api/ws2tcpip/nf-ws2tcpip-getnameinfo

Luke1410 commented 5 years ago

Thanks for the clear report and description of the issue and sorry for the delay. Obviously you are correct and we applied the suggested solution to the current trunk/master version already (internal case number: SLNET-260). Changes are scheduled to be shipped in SLikeNet 0.2.0.