]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
fix the code for pointing at the master kdc addresses. purify found
authorMarc Horowitz <marc@mit.edu>
Wed, 21 Oct 1998 02:40:32 +0000 (02:40 +0000)
committerMarc Horowitz <marc@mit.edu>
Wed, 21 Oct 1998 02:40:32 +0000 (02:40 +0000)
some UMR's.

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/marc-3des@10975 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/locate_kdc.c

index e17d7c10aa7e99aed5fe61b50dd8cef980180a36..d8187ac3a666b69665ae0b64b6b63680b68392bc 100644 (file)
@@ -46,7 +46,7 @@ krb5_locate_kdc(context, realm, addr_pp, naddrs, master_index, nmasters)
     const char *realm_kdc_names[4];
     char **masterlist, **hostlist, *host, *port, *cp;
     krb5_error_code code;
-    int i, j, out, count;
+    int i, j, out, count, ismaster;
     struct sockaddr *addr_p;
     struct sockaddr_in *sin_p;
     struct hostent *hp;
@@ -103,6 +103,9 @@ krb5_locate_kdc(context, realm, addr_pp, naddrs, master_index, nmasters)
     }
     
     if (master_index) {
+        *master_index = 0;
+       *nmasters = 0;
+
        realm_kdc_names[0] = "realms";
        realm_kdc_names[1] = host;
        realm_kdc_names[2] = "admin_server";
@@ -113,10 +116,7 @@ krb5_locate_kdc(context, realm, addr_pp, naddrs, master_index, nmasters)
 
        krb5_xfree(host);
 
-       if (code) {
-           *master_index = 0;
-           *nmasters = 0;
-       } else {
+       if (code == 0) {
            for (i=0; masterlist[i]; i++) {
                host = masterlist[i];
 
@@ -138,11 +138,10 @@ krb5_locate_kdc(context, realm, addr_pp, naddrs, master_index, nmasters)
        krb5_xfree(host);
     }
 
-    /* at this point, is master is non-NULL, then either the master kdc
+    /* at this point, if master is non-NULL, then either the master kdc
        is required, and there is one, or the master kdc is not required,
        and there may or may not be one. */
 
-
 #ifdef HAVE_NETINET_IN_H
     if (sec_udpport)
            count = count * 2;
@@ -175,10 +174,15 @@ krb5_locate_kdc(context, realm, addr_pp, naddrs, master_index, nmasters)
            continue;
        }
 
-       if (masterlist)
-           for (j=0; masterlist[j]; j++)
-               if (strcasecmp(hostlist[i], masterlist[j]) == 0)
+       ismaster = 0;
+       if (masterlist) {
+           for (j=0; masterlist[j]; j++) {
+               if (strcasecmp(hostlist[i], masterlist[j]) == 0) {
                    *master_index = out;
+                   ismaster = 1;
+               }
+           }
+       }
 
        switch (hp->h_addrtype) {
 
@@ -211,7 +215,7 @@ krb5_locate_kdc(context, realm, addr_pp, naddrs, master_index, nmasters)
        default:
            break;
        }
-       if (masterlist)
+       if (ismaster)
            *nmasters = out - *master_index;
 
        /* Free the hostlist entry we are looping over. */