pullup r17377 and r17382 from trunk
authorTom Yu <tlyu@mit.edu>
Thu, 22 Sep 2005 17:16:11 +0000 (17:16 +0000)
committerTom Yu <tlyu@mit.edu>
Thu, 22 Sep 2005 17:16:11 +0000 (17:16 +0000)
ticket: 3172
version_fixed: 1.4.3

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-4@17389 dc483132-0cff-0310-8789-dd5450dbe970

src/ChangeLog
src/aclocal.m4
src/lib/krb5/os/ChangeLog
src/lib/krb5/os/dnsglue.c

index d30760be4a70c411c396c19e789065ca086c038c..394ec1269db86897231a4fc952b399fb94885f5a 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-08  Tom Yu  <tlyu@mit.edu>
+
+       * aclocal.m4 (AC_LIBRARY_NET): Check for a few more libresolv
+       functions.
+
 2005-07-19  Tom Yu  <tlyu@mit.edu>
 
        * aclocal.m4 (AC_LIBRARY_NET): Special-case AIX 5.x due to broken
index 2806d689ad5f7326a7e566074f1c2c2b28cf0ea8..a7b1f4ad1cc6d088f00fc34fd8e533d2cc884ac1 100644 (file)
@@ -1379,16 +1379,8 @@ AC_DEFUN(AC_LIBRARY_NET, [
     # 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.
index aaeec718b6d514cdd70bc8ef9b0be2369758c521..690750cf10a449f197d75a52ae14d46c8901851a 100644 (file)
@@ -1,3 +1,16 @@
+2005-09-16  Tom Yu  <tlyu@mit.edu>
+
+       * dnsglue.c (USE_RES_NINIT): Fix braino: define to 1, not empty
+       string.
+
+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
index 5d2db36952642f9b7f0d3ed04a71f482df4cc21b..bd1eed7db32f13a9670726836d8fc91330b39479 100644 (file)
 
 #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 1
+#endif
+
 /*
  * Opaque handle
  */
@@ -53,7 +65,7 @@ static int initparse(struct krb5int_dns_state *);
 /*
  * 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.
  */
@@ -61,7 +73,7 @@ int
 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;
@@ -86,11 +98,13 @@ krb5int_dns_init(struct krb5int_dns_state **dsp,
     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)
@@ -103,7 +117,7 @@ krb5int_dns_init(struct krb5int_dns_state **dsp,
        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
@@ -134,12 +148,8 @@ krb5int_dns_init(struct krb5int_dns_state **dsp,
     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) {