summaryrefslogtreecommitdiffstats
path: root/lib/lwres
diff options
context:
space:
mode:
authorerwin <erwin@FreeBSD.org>2013-07-24 07:12:55 +0000
committererwin <erwin@FreeBSD.org>2013-07-24 07:12:55 +0000
commitdc235a59431db02e1a04d85de49af9e278510ac8 (patch)
treee392027bf54f7a1fd2a6f3a16ecb4487844b44e9 /lib/lwres
parent9ef4e0591273b7d40b98ef46084442638150b2fc (diff)
downloadFreeBSD-src-dc235a59431db02e1a04d85de49af9e278510ac8.zip
FreeBSD-src-dc235a59431db02e1a04d85de49af9e278510ac8.tar.gz
Vendor import of Bind 9.8.5-P1
Approved by: delphij (mentor) Sponsored by: DK Hostmaster A/S
Diffstat (limited to 'lib/lwres')
-rw-r--r--lib/lwres/api5
-rw-r--r--lib/lwres/context.c3
-rw-r--r--lib/lwres/getaddrinfo.c16
-rw-r--r--lib/lwres/getipnode.c14
-rw-r--r--lib/lwres/getnameinfo.c4
-rw-r--r--lib/lwres/getrrset.c54
-rw-r--r--lib/lwres/lwinetaton.c6
-rw-r--r--lib/lwres/print.c4
8 files changed, 58 insertions, 48 deletions
diff --git a/lib/lwres/api b/lib/lwres/api
index 1e51baa..2a5c388 100644
--- a/lib/lwres/api
+++ b/lib/lwres/api
@@ -1,8 +1,9 @@
# LIBINTERFACE ranges
# 9.6: 50-59, 110-119
# 9.7: 60-79
-# 9.8: 80-89
+# 9.8: 80-89, 120-129
# 9.9: 90-109
+# 9.9-sub: 130-139
LIBINTERFACE = 80
-LIBREVISION = 3
+LIBREVISION = 6
LIBAGE = 0
diff --git a/lib/lwres/context.c b/lib/lwres/context.c
index 64bdaa1..047707f 100644
--- a/lib/lwres/context.c
+++ b/lib/lwres/context.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2007-2009 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007-2009, 2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -377,6 +377,7 @@ lwres_context_send(lwres_context_t *ctx,
lwresult = context_connect(ctx);
if (lwresult != LWRES_R_SUCCESS)
return (lwresult);
+ INSIST(ctx->sock >= 0);
}
ret = sendto(ctx->sock, sendbase, sendlen, 0, NULL, 0);
diff --git a/lib/lwres/getaddrinfo.c b/lib/lwres/getaddrinfo.c
index 811a2fe..7d5f2fb 100644
--- a/lib/lwres/getaddrinfo.c
+++ b/lib/lwres/getaddrinfo.c
@@ -573,10 +573,8 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip,
(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);
+ if (ai == NULL)
SETERROR(EAI_MEMORY);
- }
*aip = ai;
ai->ai_socktype = socktype;
@@ -594,10 +592,8 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip,
addr = LWRES_LIST_HEAD(by->addrs);
while (addr != NULL) {
ai = ai_clone(*aip, AF_INET);
- if (ai == NULL) {
- lwres_freeaddrinfo(*aip);
+ if (ai == NULL)
SETERROR(EAI_MEMORY);
- }
*aip = ai;
ai->ai_socktype = socktype;
SIN(ai->ai_addr)->sin_port = port;
@@ -641,10 +637,8 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip,
if (hostname == NULL && (flags & AI_PASSIVE) == 0) {
ai = ai_clone(*aip, AF_INET6);
- if (ai == NULL) {
- lwres_freeaddrinfo(*aip);
+ if (ai == NULL)
SETERROR(EAI_MEMORY);
- }
*aip = ai;
ai->ai_socktype = socktype;
@@ -662,10 +656,8 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip,
addr = LWRES_LIST_HEAD(by->addrs);
while (addr != NULL) {
ai = ai_clone(*aip, AF_INET6);
- if (ai == NULL) {
- lwres_freeaddrinfo(*aip);
+ if (ai == NULL)
SETERROR(EAI_MEMORY);
- }
*aip = ai;
ai->ai_socktype = socktype;
SIN6(ai->ai_addr)->sin6_port = port;
diff --git a/lib/lwres/getipnode.c b/lib/lwres/getipnode.c
index 3bd8217..300376e 100644
--- a/lib/lwres/getipnode.c
+++ b/lib/lwres/getipnode.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007, 2009, 2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -466,6 +466,9 @@ lwres_freehostent(struct hostent *he) {
int names = 1;
int addresses = 1;
+ if (he == NULL)
+ return;
+
free(he->h_name);
cpp = he->h_addr_list;
@@ -950,8 +953,9 @@ copyandmerge(struct hostent *he1, struct hostent *he2, int af, int *error_num)
* Copy aliases.
*/
npp = he->h_aliases;
- cpp = (he1 != NULL) ? he1->h_aliases : he2->h_aliases;
- while (*cpp != NULL) {
+ cpp = (he1 != NULL) ? he1->h_aliases
+ : ((he2 != NULL) ? he2->h_aliases : NULL);
+ while (cpp != NULL && *cpp != NULL) {
len = strlen (*cpp) + 1;
*npp = malloc(len);
if (*npp == NULL)
@@ -1115,6 +1119,8 @@ hostfromname(lwres_gabnresponse_t *name, int af) {
* Copy aliases.
*/
he->h_aliases = malloc(sizeof(char *) * (name->naliases + 1));
+ if (he->h_aliases == NULL)
+ goto cleanup;
for (i = 0; i < name->naliases; i++) {
he->h_aliases[i] = strdup(name->aliases[i]);
if (he->h_aliases[i] == NULL)
@@ -1126,6 +1132,8 @@ hostfromname(lwres_gabnresponse_t *name, int af) {
* Copy addresses.
*/
he->h_addr_list = malloc(sizeof(char *) * (name->naddrs + 1));
+ if (he->h_addr_list == NULL)
+ goto cleanup;
addr = LWRES_LIST_HEAD(name->addrs);
i = 0;
while (addr != NULL) {
diff --git a/lib/lwres/getnameinfo.c b/lib/lwres/getnameinfo.c
index 92a34a1..08ebf93 100644
--- a/lib/lwres/getnameinfo.c
+++ b/lib/lwres/getnameinfo.c
@@ -1,5 +1,5 @@
/*
- * Portions Copyright (C) 2004, 2005, 2007, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 2004, 2005, 2007, 2011-2013 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 1999-2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -161,7 +161,7 @@ int
lwres_getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
size_t hostlen, char *serv, size_t servlen, int flags)
{
- struct afd *afd;
+ struct afd *afd = NULL;
struct servent *sp;
unsigned short port;
#ifdef LWRES_PLATFORM_HAVESALEN
diff --git a/lib/lwres/getrrset.c b/lib/lwres/getrrset.c
index d8b6cc3..16af741 100644
--- a/lib/lwres/getrrset.c
+++ b/lib/lwres/getrrset.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -21,12 +21,12 @@
/**
* DESCRIPTION
- *
+ *
* lwres_getrrsetbyname() gets a set of resource records associated with
* a hostname, class, and type. hostname is a pointer a to
* null-terminated string. The flags field is currently unused and must
* be zero.
- *
+ *
* After a successful call to lwres_getrrsetbyname(), *res is a pointer
* to an #rrsetinfo structure, containing a list of one or more #rdatainfo
* structures containing resource records and potentially another list of
@@ -37,7 +37,7 @@
* in uncompressed DNS wire format. Properties of the rdataset are
* represented in the #rri_flags bitfield. If the #RRSET_VALIDATED bit is
* set, the data has been DNSSEC validated and the signatures verified.
- *
+ *
* All of the information returned by lwres_getrrsetbyname() is
* dynamically allocated: the rrsetinfo and rdatainfo structures, and the
* canonical host name strings pointed to by the rrsetinfostructure.
@@ -45,15 +45,15 @@
* successful call to lwres_getrrsetbyname() is released by
* lwres_freerrset(). rrset is a pointer to a struct rrset created by a
* call to lwres_getrrsetbyname().
- *
+ *
* The following structures are used:
- *
+ *
* \code
* struct rdatainfo {
* unsigned int rdi_length; // length of data
* unsigned char *rdi_data; // record data
* };
- *
+ *
* struct rrsetinfo {
* unsigned int rri_flags; // RRSET_VALIDATED...
* unsigned int rri_rdclass; // class number
@@ -66,23 +66,23 @@
* struct rdatainfo *rri_sigs; // individual signatures
* };
* \endcode
- *
+ *
* \section getrrset_return Return Values
- *
+ *
* lwres_getrrsetbyname() returns zero on success, and one of the
* following error codes if an error occurred:
- *
+ *
* \li #ERRSET_NONAME: the name does not exist
- *
+ *
* \li #ERRSET_NODATA:
* the name exists, but does not have data of the desired type
- *
+ *
* \li #ERRSET_NOMEMORY:
* memory could not be allocated
- *
+ *
* \li #ERRSET_INVAL:
* a parameter is invalid
- *
+ *
* \li #ERRSET_FAIL:
* other failure
*/
@@ -179,7 +179,7 @@ lwres_getrrsetbyname(const char *hostname, unsigned int rdclass,
lwflags = 0;
lwresult = lwres_getrdatabyname(lwrctx, hostname,
- (lwres_uint16_t)rdclass,
+ (lwres_uint16_t)rdclass,
(lwres_uint16_t)rdtype,
lwflags, &response);
if (lwresult != LWRES_R_SUCCESS) {
@@ -271,18 +271,22 @@ lwres_getrrsetbyname(const char *hostname, unsigned int rdclass,
void
lwres_freerrset(struct rrsetinfo *rrset) {
unsigned int i;
- for (i = 0; i < rrset->rri_nrdatas; i++) {
- if (rrset->rri_rdatas[i].rdi_data == NULL)
- break;
- free(rrset->rri_rdatas[i].rdi_data);
+ if (rrset->rri_rdatas != NULL) {
+ for (i = 0; i < rrset->rri_nrdatas; i++) {
+ if (rrset->rri_rdatas[i].rdi_data == NULL)
+ break;
+ free(rrset->rri_rdatas[i].rdi_data);
+ }
+ free(rrset->rri_rdatas);
}
- free(rrset->rri_rdatas);
- for (i = 0; i < rrset->rri_nsigs; i++) {
- if (rrset->rri_sigs[i].rdi_data == NULL)
- break;
- free(rrset->rri_sigs[i].rdi_data);
+ if (rrset->rri_sigs != NULL) {
+ for (i = 0; i < rrset->rri_nsigs; i++) {
+ if (rrset->rri_sigs[i].rdi_data == NULL)
+ break;
+ free(rrset->rri_sigs[i].rdi_data);
+ }
+ free(rrset->rri_sigs);
}
- free(rrset->rri_sigs);
free(rrset->rri_name);
free(rrset);
}
diff --git a/lib/lwres/lwinetaton.c b/lib/lwres/lwinetaton.c
index e40c28f..5a0d85a 100644
--- a/lib/lwres/lwinetaton.c
+++ b/lib/lwres/lwinetaton.c
@@ -1,5 +1,5 @@
/*
- * Portions Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 1996-2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -95,7 +95,7 @@ static char rcsid[] = "$Id: lwinetaton.c,v 1.16 2007/06/19 23:47:22 tbox Exp $";
*/
int
lwres_net_aton(const char *cp, struct in_addr *addr) {
- unsigned long val;
+ lwres_uint32_t val;
int base, n;
unsigned char c;
lwres_uint8_t parts[4];
@@ -120,7 +120,7 @@ lwres_net_aton(const char *cp, struct in_addr *addr) {
c = *++cp;
if (c == 'x' || c == 'X') {
base = 16;
- c = *++cp;
+ c = *++cp;
} else {
base = 8;
digit = 1;
diff --git a/lib/lwres/print.c b/lib/lwres/print.c
index 591ed36..87f3032 100644
--- a/lib/lwres/print.c
+++ b/lib/lwres/print.c
@@ -470,12 +470,16 @@ lwres__print_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
pad--;
}
break;
+
case 'D': /*deprecated*/
INSIST("use %ld instead of %D" == NULL);
+ break;
case 'O': /*deprecated*/
INSIST("use %lo instead of %O" == NULL);
+ break;
case 'U': /*deprecated*/
INSIST("use %lu instead of %U" == NULL);
+ break;
case 'L':
#ifdef HAVE_LONG_DOUBLE
OpenPOWER on IntegriCloud