[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sock_to_principal bugfix



In  krb5_sock_to_principal,   the  resolver   is  used   to  determine
an   appropriate   hostname   to  pass   to   krb5_sname_to_principal.
This   hostname   needs   to   be    copied   before   the   call   to
krb5_sname_to_principal,  because  the  latter may  use  the  resolver
itself, trashing our  previous results before we are  really done with
them.  I was bitten by this on *shudder* IRIX.


--- lib/krb5/sock_principal.c	2001/07/02 18:47:08
+++ lib/krb5/sock_principal.c	2001/07/09 00:49:19
@@ -82,9 +84,16 @@
 	    }
     }
 
-    return krb5_sname_to_principal (context,
-				    hname,
-				    sname,
-				    type,
-				    ret_princ);
+    if (hname != NULL && ((hname = strdup(hname)) == NULL)) {
+	krb5_set_error_string (context, "malloc: out of memory");
+	return ENOMEM;
+    }
+    ret = krb5_sname_to_principal (context,
+				   hname,
+				   sname,
+				   type,
+				   ret_princ);
+    if (hname != NULL)
+	free(hname);
+    return ret;
 }


Cheers,
-- 
Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org