Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Stop out of bounds memory read #116

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Stop out of bounds memory read #116

wants to merge 1 commit into from

Conversation

milesbarr
Copy link

The code sometimes copies an IPv4 address with the size of an IPv6 address.

The code sometimes copies an IPv4 address with the size of an IPv6 address.
@BigJoe01
Copy link

Hi,
This section found under RecvFromBlockingIPV4And6 function,
where RAKNET_SUPPORT_IPV6 is enabled.
See socket declaration in RakNetTypes.h in line 211,
in this mode, structure size is sockaddr_in6.

union// In6OrIn4
{
#if RAKNET_SUPPORT_IPV6==1
struct sockaddr_storage sa_stor;
sockaddr_in6 addr6;
#endif

	sockaddr_in addr4;
} address;

@milesbarr
Copy link
Author

It is actually the aip->ai_addr value returned by getaddrinfo which can contain an IPv4 address (on Windows at least). memcpy is passed the size of an IPv6 address, which will read out of bounds on the iap->ai_addr value.

@BigJoe01
Copy link

BigJoe01 commented Jul 30, 2017

In PrepareAddrInfoHints2(&hints) protocol settings is not defined, getaddrinfo send back all ipv4 and ipv6 address. Need checking assigned ipv6 and ipv4 addresses. Ipv4 address assigned to nic?

@Luke1410
Copy link

Luke1410 commented Apr 24, 2018

@milesbarr , nice catch and thanks for the contribution. I just applied your changes to SLikeNet. It's available in the SVN and GitHub repositories (https://github.com/SLikeSoft/SLikeNet) and is expected to get shipped with SLikeNet 0.2.0 (internal case number: SLNET-202).

@Luke1410
Copy link

Luke1410 commented May 8, 2018

Since we did an unplanned release of SLikeNet, we decided to incorporate this pull request (aka: case SLNET-202) in SLikeNet 0.1.2 already which is available now on https://www.slikenet.com/ and on the GitHub project page: https://github.com/SLikeSoft/SLikeNet/releases/tag/v.0.1.2 .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants