Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
socket: fix possible buffer overflow in listen_port()
At some point in listen_port(), we memcpy() the IP address -- ai_addr field (struct sockaddr), but used, as the size, the ai_addrlen field from ptr, which is struct addrinfo. This means that, for IPv4, we had ai_addrlen being 16, while for IPv6, it was 28. The problem is that we copy this address to a struct sockaddr, which has sizeof 16. This issue was exposed by running this under i686 with D_FORTIFY_SOURCE enabled, as we got a buffer overflow upon starting. This commit changes the memcpy() call to use the correct size for the destination memory area.
- Loading branch information