From 0f603f72496ff9ba52a1b6af75b8c8c4a45e67df Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Sun, 4 Jul 2004 08:48:21 +0000 Subject: [PATCH] * dnssrv.c (krb5int_make_srv_query_realm) [HAVE_RES_NSEARCH]: Use res_nsearch instead of res_search. * hst_realm.c (krb5_try_realm_txt_rr) [HAVE_RES_NSEARCH]: Likewise. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16541 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 7 +++++++ src/lib/krb5/os/dnssrv.c | 28 ++++++++++++++++++++++++++++ src/lib/krb5/os/hst_realm.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index fcba1f33c..4efd66d12 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,10 @@ +2004-07-04 Ken Raeburn + + * dnssrv.c (krb5int_make_srv_query_realm) [HAVE_RES_NSEARCH]: Use + res_nsearch instead of res_search. + * hst_realm.c (krb5_try_realm_txt_rr) [HAVE_RES_NSEARCH]: + Likewise. + 2004-07-02 Ken Raeburn * an_to_ln.c: Include string.h. diff --git a/src/lib/krb5/os/dnssrv.c b/src/lib/krb5/os/dnssrv.c index 1c1586a8a..400217975 100644 --- a/src/lib/krb5/os/dnssrv.c +++ b/src/lib/krb5/os/dnssrv.c @@ -128,7 +128,35 @@ krb5int_make_srv_query_realm(const krb5_data *realm, fprintf (stderr, "sending DNS SRV query for %s\n", host); #endif +#ifdef HAVE_RES_NSEARCH + { + res_state statp; + /* Weird... the man pages I've been looking at (Solaris 9) say + we pass a res_state object (which is a pointer) into + various routines, but they don't say much of anything about + what it should point to initially or how it should be + allocated. + + They also give no indication what the return value of + res_ninit is. */ + typedef union { + struct sockaddr_storage ss; + INT64_TYPE i64; + double d; + } aligned_thing; + aligned_thing statp_buf[(sizeof(*statp) + sizeof(aligned_thing) - 1) / sizeof(aligned_thing)]; + int n; + + statp = (res_state) &statp_buf; + memset(&statp_buf, 0, sizeof(statp_buf)); + n = res_ninit(statp); + /* ignore n? */ + size = res_nsearch(statp, host, C_IN, T_SRV, + answer.bytes, sizeof(answer.bytes)); + } +#else size = res_search(host, C_IN, T_SRV, answer.bytes, sizeof(answer.bytes)); +#endif if ((size < hdrsize) || (size > sizeof(answer.bytes))) goto out; diff --git a/src/lib/krb5/os/hst_realm.c b/src/lib/krb5/os/hst_realm.c index a72fb846c..bdf7e8d09 100644 --- a/src/lib/krb5/os/hst_realm.c +++ b/src/lib/krb5/os/hst_realm.c @@ -143,7 +143,35 @@ krb5_try_realm_txt_rr(const char *prefix, const char *name, char **realm) if ((h > host) && (h[-1] != '.') && ((h - host + 1) < sizeof(host))) strcpy (h, "."); } +#ifdef HAVE_RES_NSEARCH + { + res_state statp; + /* Weird... the man pages I've been looking at (Solaris 9) say + we pass a res_state object (which is a pointer) into + various routines, but they don't say much of anything about + what it should point to initially or how it should be + allocated. + + They also give no indication what the return value of + res_ninit is. */ + typedef union { + struct sockaddr_storage ss; + INT64_TYPE i64; + double d; + } aligned_thing; + aligned_thing statp_buf[(sizeof(*statp) + sizeof(aligned_thing) - 1) / sizeof(aligned_thing)]; + int n; + + statp = (res_state) &statp_buf; + memset(&statp_buf, 0, sizeof(statp_buf)); + n = res_ninit(statp); + /* ignore n? */ + size = res_nsearch(statp, host, C_IN, T_TXT, + answer.bytes, sizeof(answer.bytes)); + } +#else size = res_search(host, C_IN, T_TXT, answer.bytes, sizeof(answer.bytes)); +#endif if ((size < sizeof(HEADER)) || (size > sizeof(answer.bytes))) return KRB5_ERR_HOST_REALM_UNKNOWN; -- 2.26.2