Fix logic error that can result in a potential crash (when getaddrinfo() fails
and res happened to be NULL). Also add missing freeaddrinfo() call. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@188 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
[Changes 1.2c01]
|
||||
|
||||
* Fix leak and potential crash in lame_resolv() using IPv6. (caf, snadge)
|
||||
|
||||
* Apply patch from snadge defining BIND_4_COMPAT on OpenBSD, to allow
|
||||
/nslookup to build. (caf)
|
||||
|
||||
|
||||
@@ -639,10 +639,11 @@ 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)
|
||||
return -1;
|
||||
|
||||
memmove(buffer, res->ai_addr, res->ai_addrlen);
|
||||
freeaddrinfo(res);
|
||||
return 0;
|
||||
#else
|
||||
struct hostent *hp;
|
||||
|
||||
Reference in New Issue
Block a user