[2804] in Kerberos-V5-bugs

home help back first fref pref prev next nref lref last post

krb5-libs/484: The Win32 code doesn't work if your local machine is multihomed

daemon@ATHENA.MIT.EDU (Ken Hornstein)
Fri Oct 24 17:20:23 1997

Resent-From: gnats@rt-11.MIT.EDU (GNATS Management)
Resent-To: krb5-unassigned@RT-11.MIT.EDU
Resent-Reply-To: krb5-bugs@MIT.EDU, kenh@cmf.nrl.navy.mil
Date: Fri, 24 Oct 1997 17:18:48 -0400 (EDT)
From: Ken Hornstein <kenh@cmf.nrl.navy.mil>
Reply-To: kenh@cmf.nrl.navy.mil
To: krb5-bugs@MIT.EDU


>Number:         484
>Category:       krb5-libs
>Synopsis:       krb5_crypto_os_localaddr() doesn't support multihomed Win32 machines
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    krb5-unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Fri Oct 24 17:20:00 EDT 1997
>Last-Modified:
>Originator:     Ken Hornstein
>Organization:
Navel Research Lab
	
>Release:        krb5-current
>Environment:
	
System: Windows 95
Architecture: win32

>Description:
	
The calls to krb5_crypto_os_localaddr() that do the magic for Win32 machines
don't handle multihomed machines.  So, depending on the address list you get
back, you might not be able to use Kerberos.
>How-To-Repeat:
	
Try Kerberos on a multihomed NT box.
>Fix:
	
--- lib/crypto/os/c_localaddr.c.orig	Fri Oct 24 14:34:02 1997
+++ lib/crypto/os/c_localaddr.c	Fri Oct 24 16:45:02 1997
@@ -294,11 +294,7 @@
 krb5_crypto_os_localaddr (krb5_address ***addr) {
     char host[64];                              /* Name of local machine */
     struct hostent *hostrec;
-    int err;
-
-    *addr = calloc (2, sizeof (krb5_address *));
-    if (*addr == NULL)
-        return ENOMEM;
+    int err, i;
 
 #ifdef HAVE_MACSOCK_H
     hostrec = getmyipaddr();
@@ -323,26 +319,45 @@
     }
 #endif /* HAVE_MACSOCK_H */
 
-    (*addr)[0] = calloc (1, sizeof(krb5_address));
-    if ((*addr)[0] == NULL) {
-        free (*addr);
-        return ENOMEM;
-    }
-    (*addr)[0]->magic = KV5M_ADDRESS;
-    (*addr)[0]->addrtype = hostrec->h_addrtype;
-    (*addr)[0]->length = hostrec->h_length;
-    (*addr)[0]->contents = (unsigned char *)malloc((*addr)[0]->length);
-    if (!(*addr)[0]->contents) {
-        free((*addr)[0]);
-        free(*addr);
+    /*
+     * Count the elements in the host address list
+     */
+
+    for (i = 0; hostrec->h_addr_list[i]; i++);
+
+    *addr = calloc ((i+1), sizeof (krb5_address *));
+    if (*addr == NULL)
         return ENOMEM;
-    } else {
-        memcpy ((*addr)[0]->contents,
-                hostrec->h_addr,
-                (*addr)[0]->length);
+
+    for (i = 0; hostrec->h_addr_list[i]; i++) {
+	(*addr)[i] = calloc (1, sizeof(krb5_address));
+
+	if ((*addr)[i] == NULL)
+	    goto nomem;
+
+	(*addr)[i]->magic = KV5M_ADDRESS;
+	(*addr)[i]->addrtype = hostrec->h_addrtype;
+	(*addr)[i]->length = hostrec->h_length;
+	(*addr)[i]->contents = (unsigned char *)malloc((*addr)[i]->length);
+
+	if (!(*addr)[i]->contents) {
+	    goto nomem;
+	} else {
+	    memcpy ((*addr)[i]->contents, hostrec->h_addr_list[i],
+		    (*addr)[i]->length);
+	}
     }
-	/* FIXME, deal with the case where gethostent returns multiple addrs */
 
     return(0);
+
+nomem:
+
+    for (i = 0; (*addr)[i]; i++) {
+	if ((*addr)[i]->contents)
+	    free((*addr)[i]->contents);
+	free((*addr)[i]);
+    }
+    free(*addr);
+    return ENOMEM;
 }
 #endif
>Audit-Trail:
>Unformatted:

home help back first fref pref prev next nref lref last post