From 8c86041853d617eabe613a5906279f8258a543df Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Tue, 10 Apr 2007 21:51:59 +0000 Subject: [PATCH] pull up r19399 from trunk r19399@cathode-dark-space: raeburn | 2007-04-05 16:22:28 -0400 ticket: new subject: service location plugin returning no addresses handled incorrectly If a locate plugin (e.g., the Python sample plugin and script, when given realm BOBO.MIT.EDU) returns no error but no addresses, the library won't report an error, but will try to make contact, and eventually crash with a null pointer dereference. Fix: If a plugin returns a value other than PLUGIN_NO_HANDLE, including success, continue into the code that checks for an empty address list. ticket: 5509 version_fixed: 1.6.1 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-6@19416 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/locate_kdc.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index 57e2456b9..61ffe8c82 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -778,28 +778,28 @@ krb5int_locate_server (krb5_context context, const krb5_data *realm, code = module_locate_server(context, realm, &al, svc, socktype, family); Tprintf("module_locate_server returns %d\n", code); - if (code != KRB5_PLUGIN_NO_HANDLE) { - *addrlist = al; - return code; - } - - /* - * We always try the local file before DNS - */ - - code = prof_locate_server(context, realm, &al, svc, socktype, family); + if (code == KRB5_PLUGIN_NO_HANDLE) { + /* + * We always try the local file before DNS. Note that there + * is no way to indicate "service not available" via the + * config file. + */ - /* We could put more heuristics here, like looking up a hostname - of "kerberos."+REALM, etc. */ + code = prof_locate_server(context, realm, &al, svc, socktype, family); #ifdef KRB5_DNS_LOOKUP - if (code) { - krb5_error_code code2; - code2 = dns_locate_server(context, realm, &al, svc, socktype, family); - if (code2 != KRB5_PLUGIN_NO_HANDLE) - code = code2; - } + if (code) { /* Try DNS for all profile errors? */ + krb5_error_code code2; + code2 = dns_locate_server(context, realm, &al, svc, socktype, + family); + if (code2 != KRB5_PLUGIN_NO_HANDLE) + code = code2; + } #endif /* KRB5_DNS_LOOKUP */ + + /* We could put more heuristics here, like looking up a hostname + of "kerberos."+REALM, etc. */ + } if (code == 0) Tprintf ("krb5int_locate_server found %d addresses\n", al.naddrs); -- 2.26.2