diff --git a/CHANGES b/CHANGES index ad76c227ff..3cf0c6d6bc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +1185. [bug] libbind: don't assume statp->_u._ext.ext is valid + unless RES_INIT is set when calling res_*init(). + +1184. [bug] libbind: call res_ndestroy() if RES_INIT is set + when res_*init() is called. + 1183. [bug] Handle ENOSR error when writing to the internal control pipe. [RT #2395] diff --git a/lib/bind/resolv/res_init.c b/lib/bind/resolv/res_init.c index 198dfd4b9f..648f0e61fb 100644 --- a/lib/bind/resolv/res_init.c +++ b/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.10 2001/11/01 04:50:59 marka Exp $"; +static const char rcsid[] = "$Id: res_init.c,v 1.11 2002/01/22 03:16:28 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -169,6 +169,9 @@ __res_vinit(res_state statp, int preinit) { statp->id = res_randomid(); } + if ((statp->options & RES_INIT) != 0) + res_ndestroy(statp); + #ifdef USELOOPBACK statp->nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1); #else @@ -187,14 +190,12 @@ __res_vinit(res_state statp, int preinit) { statp->qhook = NULL; statp->rhook = NULL; statp->_u._ext.nscount = 0; - if (statp->_u._ext.ext == NULL) { - statp->_u._ext.ext = malloc(sizeof(*statp->_u._ext.ext)); - if (statp->_u._ext.ext != NULL) { + statp->_u._ext.ext = malloc(sizeof(*statp->_u._ext.ext)); + if (statp->_u._ext.ext != NULL) { memset(statp->_u._ext.ext, 0, sizeof(*statp->_u._ext.ext)); statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr; strcpy(statp->_u._ext.ext->nsuffix, "ip6.int"); strcpy(statp->_u._ext.ext->bsuffix, "ip6.arpa"); - } } #ifdef RESOLVSORT statp->nsort = 0;