From: Tom Yu Date: Thu, 22 Sep 2005 17:16:11 +0000 (+0000) Subject: pullup r17377 and r17382 from trunk X-Git-Tag: krb5-1.4.3-beta1~23 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=99b95abc2026ffe8652347e3b00309cc4e668cb8;p=krb5.git pullup r17377 and r17382 from trunk 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index d30760be4..394ec1269 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-09-08 Tom Yu + + * aclocal.m4 (AC_LIBRARY_NET): Check for a few more libresolv + functions. + 2005-07-19 Tom Yu * aclocal.m4 (AC_LIBRARY_NET): Special-case AIX 5.x due to broken diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 2806d689a..a7b1f4ad1 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -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. diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index aaeec718b..690750cf1 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,16 @@ +2005-09-16 Tom Yu + + * dnsglue.c (USE_RES_NINIT): Fix braino: define to 1, not empty + string. + +2005-09-08 Tom Yu + + * 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 * sendto_kdc.c (service_fds): Don't create a select_state on the diff --git a/src/lib/krb5/os/dnsglue.c b/src/lib/krb5/os/dnsglue.c index 5d2db3695..bd1eed7db 100644 --- a/src/lib/krb5/os/dnsglue.c +++ b/src/lib/krb5/os/dnsglue.c @@ -28,6 +28,18 @@ #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) {