summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/lib/lwres/getaddrinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/lib/lwres/getaddrinfo.c')
-rw-r--r--contrib/bind9/lib/lwres/getaddrinfo.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/contrib/bind9/lib/lwres/getaddrinfo.c b/contrib/bind9/lib/lwres/getaddrinfo.c
index c063274..9ad10df 100644
--- a/contrib/bind9/lib/lwres/getaddrinfo.c
+++ b/contrib/bind9/lib/lwres/getaddrinfo.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* This code is derived from software contributed to ISC by
@@ -18,7 +18,7 @@
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: getaddrinfo.c,v 1.41.206.3 2005/06/09 23:54:33 marka Exp $ */
+/* $Id: getaddrinfo.c,v 1.41.206.6 2006/11/13 11:57:41 marka Exp $ */
#include <config.h>
@@ -325,8 +325,10 @@ lwres_getaddrinfo(const char *hostname, const char *servname,
NULL, 0,
NI_NUMERICHOST) == 0) {
ai->ai_canonname = strdup(nbuf);
- if (ai->ai_canonname == NULL)
+ if (ai->ai_canonname == NULL) {
+ lwres_freeaddrinfo(ai_list);
return (EAI_MEMORY);
+ }
} else {
/* XXX raise error? */
ai->ai_canonname = NULL;
@@ -435,7 +437,7 @@ static char v4_loop[4] = { 127, 0, 0, 1 };
* The test against 0 is there to keep the Solaris compiler
* from complaining about "end-of-loop code not reached".
*/
-#define ERR(code) \
+#define SETERROR(code) \
do { result = (code); \
if (result != 0) goto cleanup; \
} while (0)
@@ -453,13 +455,13 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip,
lwres = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0);
if (lwres != LWRES_R_SUCCESS)
- ERR(EAI_FAIL);
+ SETERROR(EAI_FAIL);
(void) lwres_conf_parse(lwrctx, lwres_resolv_conf);
if (hostname == NULL && (flags & AI_PASSIVE) == 0) {
ai = ai_clone(*aip, AF_INET);
if (ai == NULL) {
lwres_freeaddrinfo(*aip);
- ERR(EAI_MEMORY);
+ SETERROR(EAI_MEMORY);
}
*aip = ai;
@@ -473,14 +475,14 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip,
if (lwres == LWRES_R_NOTFOUND)
goto cleanup;
else
- ERR(EAI_FAIL);
+ SETERROR(EAI_FAIL);
}
addr = LWRES_LIST_HEAD(by->addrs);
while (addr != NULL) {
ai = ai_clone(*aip, AF_INET);
if (ai == NULL) {
lwres_freeaddrinfo(*aip);
- ERR(EAI_MEMORY);
+ SETERROR(EAI_MEMORY);
}
*aip = ai;
ai->ai_socktype = socktype;
@@ -490,7 +492,7 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip,
if (flags & AI_CANONNAME) {
ai->ai_canonname = strdup(by->realname);
if (ai->ai_canonname == NULL)
- ERR(EAI_MEMORY);
+ SETERROR(EAI_MEMORY);
}
addr = LWRES_LIST_NEXT(addr, link);
}
@@ -520,14 +522,14 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip,
lwres = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0);
if (lwres != LWRES_R_SUCCESS)
- ERR(EAI_FAIL);
+ SETERROR(EAI_FAIL);
(void) lwres_conf_parse(lwrctx, lwres_resolv_conf);
if (hostname == NULL && (flags & AI_PASSIVE) == 0) {
ai = ai_clone(*aip, AF_INET6);
if (ai == NULL) {
lwres_freeaddrinfo(*aip);
- ERR(EAI_MEMORY);
+ SETERROR(EAI_MEMORY);
}
*aip = ai;
@@ -541,14 +543,14 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip,
if (lwres == LWRES_R_NOTFOUND)
goto cleanup;
else
- ERR(EAI_FAIL);
+ SETERROR(EAI_FAIL);
}
addr = LWRES_LIST_HEAD(by->addrs);
while (addr != NULL) {
ai = ai_clone(*aip, AF_INET6);
if (ai == NULL) {
lwres_freeaddrinfo(*aip);
- ERR(EAI_MEMORY);
+ SETERROR(EAI_MEMORY);
}
*aip = ai;
ai->ai_socktype = socktype;
@@ -558,7 +560,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip,
if (flags & AI_CANONNAME) {
ai->ai_canonname = strdup(by->realname);
if (ai->ai_canonname == NULL)
- ERR(EAI_MEMORY);
+ SETERROR(EAI_MEMORY);
}
addr = LWRES_LIST_NEXT(addr, link);
}
OpenPOWER on IntegriCloud