Add a length sanity check - just in case there's an implementation out there

that parses AF_UNIX addresses in getaddrinfo() or something.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@189 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Kevin Easton
2012-05-15 14:01:42 +00:00
parent ba365bfd54
commit ab7d59f1f6

View File

@@ -639,7 +639,8 @@ int lame_resolv (const char *hostname, struct sockaddr_foobar *buffer)
{
#ifdef IPV6
struct addrinfo *res;
if (getaddrinfo(hostname, NULL, NULL, &res) || !res)
if (getaddrinfo(hostname, NULL, NULL, &res) || !res ||
res->ai_addrlen > sizeof *buffer)
return -1;
memmove(buffer, res->ai_addr, res->ai_addrlen);