From 56931e5829d413d3fc1005bde07cae584603412e Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Fri, 6 Jun 2003 23:07:55 +0000 Subject: [PATCH] * locate_kdc.c (struct srv_dns_entry): Moved to k5-int.h. (krb5int_make_srv_query_realm): Renamed from make_srv_query_realm. (krb5int_free_srv_dns_data): New function. (krb5_locate_srv_dns_1): Use it. * accessor.c (krb5int_accessor): Fill in make_srv_query_realm and free_srv_dns_data fields. ticket: 1550 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15596 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 10 ++++++++++ src/lib/krb5/os/accessor.c | 7 +++++++ src/lib/krb5/os/locate_kdc.c | 37 +++++++++++++++++------------------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index 81c205665..5a0d718a1 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,13 @@ +2003-06-06 Ken Raeburn + + * locate_kdc.c (struct srv_dns_entry): Moved to k5-int.h. + (krb5int_make_srv_query_realm): Renamed from make_srv_query_realm. + (krb5int_free_srv_dns_data): New function. + (krb5_locate_srv_dns_1): Use it. + + * accessor.c (krb5int_accessor): Fill in make_srv_query_realm and + free_srv_dns_data fields. + 2003-06-05 Ken Raeburn * locate_kdc.c (make_srv_query_realm): Punt if strdup fails. diff --git a/src/lib/krb5/os/accessor.c b/src/lib/krb5/os/accessor.c index 04524d7c8..3b38e5441 100644 --- a/src/lib/krb5/os/accessor.c +++ b/src/lib/krb5/os/accessor.c @@ -42,6 +42,13 @@ krb5int_accessor(krb5int_access *internals, krb5_int32 version) internals_temp.locate_server = &krb5int_locate_server; internals_temp.sendto_udp = &krb5int_sendto; internals_temp.add_host_to_list = krb5int_add_host_to_list; +#ifdef KRB5_DNS_LOOKUP + internals_temp.make_srv_query_realm = krb5int_make_srv_query_realm; + internals_temp.free_srv_dns_data = krb5int_free_srv_dns_data; +#else + internals_temp.make_srv_query_realm = 0; + internals_temp.free_srv_dns_data = 0; +#endif #ifdef KRB5_KRB4_COMPAT internals_temp.krb_life_to_time = krb5int_krb_life_to_time; internals_temp.krb_time_to_life = krb5int_krb_time_to_life; diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index 804dc7aae..aad17e42c 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -508,24 +508,29 @@ krb5_locate_srv_conf(krb5_context context, const krb5_data *realm, * Lookup a KDC via DNS SRV records */ -struct srv_dns_entry { +void krb5int_free_srv_dns_data (struct srv_dns_entry *p) +{ struct srv_dns_entry *next; - int priority; - int weight; - unsigned short port; - char *host; -}; + while (p) { + next = p->next; + free(p->host); + free(p); + p = next; + } +} /* Do DNS SRV query, return results in *answers. Make best effort to return all the data we can. On memory or decoding errors, just return what we've got. Always return 0, currently. */ -static krb5_error_code -make_srv_query_realm(const krb5_data *realm, - const char *service, - const char *protocol, - struct srv_dns_entry **answers) +#define make_srv_query_realm krb5int_make_srv_query_realm + +krb5_error_code +krb5int_make_srv_query_realm(const krb5_data *realm, + const char *service, + const char *protocol, + struct srv_dns_entry **answers) { union { unsigned char bytes[2048]; @@ -776,15 +781,7 @@ krb5_locate_srv_dns_1 (const krb5_data *realm, fprintf (stderr, "[end]\n"); #endif - for (entry = head; entry != NULL; ) { - struct srv_dns_entry *srv; - free(entry->host); - entry->host = NULL; - srv = entry; - entry = entry->next; - free(srv); - } - + krb5int_free_srv_dns_data(head); return code; } #endif /* KRB5_DNS_LOOKUP */ -- 2.26.2