+2005-09-08 Tom Yu <tlyu@mit.edu>
+
+ * aclocal.m4 (AC_LIBRARY_NET): Check for a few more libresolv
+ functions.
+
2005-08-20 Ken Raeburn <raeburn@mit.edu>
* aclocal.m4 (K5_AC_INIT, K5_BUGADDR): New macros.
# This may get us a gethostby* that doesn't respect nsswitch.
AC_CHECK_LIB(resolv, main)
- case $krb5_cv_host in
- *-*-aix5*)
- # AIX 5 has broken res_ninit due to resolv.h not having the correct
- # size of struct __res_state; since we switch off of res_nsearch()
- # rather than res_ninit(), pretend res_nsearch() is not available.
- krb5_cv_func_res_nsearch=no
- ;;
- esac
-_KRB5_AC_CHECK_RES_FUNCS(res_nsearch res_search ns_initparse dnl
-ns_name_uncompress dn_skipname res_ndestroy)
+_KRB5_AC_CHECK_RES_FUNCS(res_ninit res_nclose res_ndestroy res_nsearch dnl
+ns_initparse ns_name_uncompress dn_skipname res_search)
if test $krb5_cv_func_res_nsearch = no \
&& test $krb5_cv_func_res_search = no; then
# Attempt to link with res_search(), in case it's not prototyped.
+2005-09-08 Tom Yu <tlyu@mit.edu>
+
+ * dnsglue.c: Implement better logic for choosing whether to use
+ res_ninit(). If res_ndestroy() doesn't exist, assume that
+ res_ninit() is broken and use res_init(), res_search(),
+ etc. instead, on the theory that the OS vendor has made the older
+ interfaces thread-safe.
+
2005-06-09 Ken Raeburn <raeburn@mit.edu>
* sendto_kdc.c (service_fds): Don't create a select_state on the
#include "dnsglue.h"
+/*
+ * Only use res_ninit() if there's also a res_ndestroy(), to avoid
+ * memory leaks (Linux & Solaris) and outright corruption (AIX 4.x,
+ * 5.x). While we're at it, make sure res_nsearch() is there too.
+ *
+ * In any case, it is probable that platforms having broken
+ * res_ninit() will have thread safety hacks for res_init() and _res.
+ */
+#if HAVE_RES_NINIT && HAVE_RES_NDESTROY && HAVE_RES_NSEARCH
+#define USE_RES_NINIT
+#endif
+
/*
* Opaque handle
*/
/*
* krb5int_dns_init()
*
- * Initialize an opaue handl. Do name lookup and initial parsing of
+ * Initialize an opaque handle. Do name lookup and initial parsing of
* reply, skipping question section. Prepare to iterate over answer
* section. Returns -1 on error, 0 on success.
*/
krb5int_dns_init(struct krb5int_dns_state **dsp,
char *host, int nclass, int ntype)
{
-#if HAVE_RES_NSEARCH
+#if USE_RES_NINIT
struct __res_state statbuf;
#endif
struct krb5int_dns_state *ds;
ds->cur_ans = 0;
#endif
-#if HAVE_RES_NSEARCH
+#if USE_RES_NINIT
ret = res_ninit(&statbuf);
+#else
+ ret = res_init();
+#endif
if (ret < 0)
return -1;
-#endif
do {
p = (ds->ansp == NULL)
ds->ansp = p;
ds->ansmax = nextincr;
-#if HAVE_RES_NSEARCH
+#if USE_RES_NINIT
len = res_nsearch(&statbuf, host, ds->nclass, ds->ntype,
ds->ansp, ds->ansmax);
#else
ret = 0;
errout:
-#if HAVE_RES_NSEARCH
-#if HAVE_RES_NDESTROY
+#if USE_RES_NINIT
res_ndestroy(&statbuf);
-#else
- res_nclose(&statbuf);
-#endif
#endif
if (ret < 0) {
if (ds->ansp != NULL) {