summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/lib/bind/resolv
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/lib/bind/resolv')
-rw-r--r--contrib/bind9/lib/bind/resolv/mtctxres.c7
-rw-r--r--contrib/bind9/lib/bind/resolv/res_init.c17
-rw-r--r--contrib/bind9/lib/bind/resolv/res_send.c17
-rw-r--r--contrib/bind9/lib/bind/resolv/res_sendsigned.c5
4 files changed, 21 insertions, 25 deletions
diff --git a/contrib/bind9/lib/bind/resolv/mtctxres.c b/contrib/bind9/lib/bind/resolv/mtctxres.c
index f33cf11..635bbd4 100644
--- a/contrib/bind9/lib/bind/resolv/mtctxres.c
+++ b/contrib/bind9/lib/bind/resolv/mtctxres.c
@@ -106,9 +106,10 @@ ___mtctxres(void) {
*/
if (!mt_key_initialized) {
static pthread_mutex_t keylock = PTHREAD_MUTEX_INITIALIZER;
- pthread_mutex_lock(&keylock);
- _mtctxres_init();
- pthread_mutex_unlock(&keylock);
+ if (pthread_mutex_lock(&keylock) == 0) {
+ _mtctxres_init();
+ (void) pthread_mutex_unlock(&keylock);
+ }
}
/*
diff --git a/contrib/bind9/lib/bind/resolv/res_init.c b/contrib/bind9/lib/bind/resolv/res_init.c
index 28a3ebd..fd82e872 100644
--- a/contrib/bind9/lib/bind/resolv/res_init.c
+++ b/contrib/bind9/lib/bind/resolv/res_init.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
-static const char rcsid[] = "$Id: res_init.c,v 1.9.2.5.4.5 2005/11/03 00:00:52 marka Exp $";
+static const char rcsid[] = "$Id: res_init.c,v 1.9.2.5.4.6 2006/08/30 23:23:01 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -237,17 +237,10 @@ __res_vinit(res_state statp, int preinit) {
if (buf[0] == '+')
buf[0] = '.';
cp = strchr(buf, '.');
- if (cp == NULL) {
- if (strlcpy(statp->defdname, buf,
- sizeof(statp->defdname))
- >= sizeof(statp->defdname))
- goto freedata;
- } else {
- if (strlcpy(statp->defdname, cp+1,
- sizeof(statp->defdname))
- >= sizeof(statp->defdname))
- goto freedata;
- }
+ cp = (cp == NULL) ? buf : (cp + 1);
+ if (strlen(cp) >= sizeof(statp->defdname))
+ goto freedata;
+ strcpy(statp->defdname, cp);
}
}
#endif /* SOLARIS2 */
diff --git a/contrib/bind9/lib/bind/resolv/res_send.c b/contrib/bind9/lib/bind/resolv/res_send.c
index 5be2489..c47dd49 100644
--- a/contrib/bind9/lib/bind/resolv/res_send.c
+++ b/contrib/bind9/lib/bind/resolv/res_send.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_send.c,v 1.5.2.2.4.7 2005/08/15 02:04:41 marka Exp $";
+static const char rcsid[] = "$Id: res_send.c,v 1.5.2.2.4.9 2006/10/16 23:00:50 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -130,7 +130,7 @@ static struct sockaddr * get_nsaddr __P((res_state, size_t));
static int send_vc(res_state, const u_char *, int,
u_char *, int, int *, int);
static int send_dg(res_state, const u_char *, int,
- u_char *, int, int *, int,
+ u_char *, int, int *, int, int,
int *, int *);
static void Aerror(const res_state, FILE *, const char *, int,
const struct sockaddr *, int);
@@ -295,7 +295,8 @@ res_nsend(res_state statp,
highestFD = sysconf(_SC_OPEN_MAX) - 1;
#endif
- if (statp->nscount == 0) {
+ /* No name servers or res_init() failure */
+ if (statp->nscount == 0 || EXT(statp).ext == NULL) {
errno = ESRCH;
return (-1);
}
@@ -458,7 +459,7 @@ res_nsend(res_state statp,
} else {
/* Use datagrams. */
n = send_dg(statp, buf, buflen, ans, anssiz, &terrno,
- ns, &v_circuit, &gotsomewhere);
+ ns, try, &v_circuit, &gotsomewhere);
if (n < 0)
goto fail;
if (n == 0)
@@ -766,9 +767,9 @@ send_vc(res_state statp,
}
static int
-send_dg(res_state statp,
- const u_char *buf, int buflen, u_char *ans, int anssiz,
- int *terrno, int ns, int *v_circuit, int *gotsomewhere)
+send_dg(res_state statp, const u_char *buf, int buflen, u_char *ans,
+ int anssiz, int *terrno, int ns, int try, int *v_circuit,
+ int *gotsomewhere)
{
const HEADER *hp = (const HEADER *) buf;
HEADER *anhp = (HEADER *) ans;
@@ -849,7 +850,7 @@ send_dg(res_state statp,
/*
* Wait for reply.
*/
- seconds = (statp->retrans << ns);
+ seconds = (statp->retrans << try);
if (ns > 0)
seconds /= statp->nscount;
if (seconds <= 0)
diff --git a/contrib/bind9/lib/bind/resolv/res_sendsigned.c b/contrib/bind9/lib/bind/resolv/res_sendsigned.c
index d1d2274..93ad5c9 100644
--- a/contrib/bind9/lib/bind/resolv/res_sendsigned.c
+++ b/contrib/bind9/lib/bind/resolv/res_sendsigned.c
@@ -52,6 +52,7 @@ res_nsendsigned(res_state statp, const u_char *msg, int msglen,
bufsize = msglen + 1024;
newmsg = (u_char *) malloc(bufsize);
if (newmsg == NULL) {
+ free(nstatp);
errno = ENOMEM;
return (-1);
}
@@ -102,11 +103,11 @@ res_nsendsigned(res_state statp, const u_char *msg, int msglen,
retry:
len = res_nsend(nstatp, newmsg, newmsglen, answer, anslen);
- if (ret < 0) {
+ if (len < 0) {
free (nstatp);
free (newmsg);
dst_free_key(dstkey);
- return (ret);
+ return (len);
}
ret = ns_verify(answer, &len, dstkey, sig, siglen,
OpenPOWER on IntegriCloud