* kcmd.c (kcmd): Use krb5_set_principal_realm() instead of freeing the
authorEzra Peisach <epeisach@mit.edu>
Tue, 10 Oct 2000 09:00:59 +0000 (09:00 +0000)
committerEzra Peisach <epeisach@mit.edu>
Tue, 10 Oct 2000 09:00:59 +0000 (09:00 +0000)
        principals realm data and mucking with it ourselves.

This way, we do not free memory allocated by the krb5 library with
a possibly incorrect free, and we do not allocate memory
for a krb5 structure which might be released by the krb5 library.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12748 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/bsd/ChangeLog
src/appl/bsd/kcmd.c

index 50bf2c24dc002a4be49f47b9f2ac174ab559367d..eb4748a72cee56034699f455de6c9758731f7c33 100644 (file)
@@ -1,3 +1,8 @@
+Tue Oct 10 04:59:04 2000  Ezra Peisach  <epeisach@mit.edu>
+
+       * kcmd.c (kcmd): Use krb5_set_principal_realm() instead of freeing the
+       principals realm data and mucking with it ourselves.
+
 2000-10-03  Ezra Peisach  <epeisach@mit.edu>
 
        * krlogin.c (main): Declare main as int.
index 3e401ccedb243b6018e538b74f36c1ece0622b28..568675fca15c44039c7b369d1da136d57d1375e1 100644 (file)
@@ -298,11 +298,13 @@ kcmd(sock, ahost, rport, locuser, remuser, cmd, fd2p, service, realm,
     }
 
     if (realm && *realm) {
-       free(krb5_princ_realm(bsd_context,get_cred->server)->data);
-       /*krb5_xfree(krb5_princ_realm(bsd_context,get_cred->server)->data);*/
-
-       krb5_princ_set_realm_length(bsd_context,get_cred->server,strlen(realm));
-       krb5_princ_set_realm_data(bsd_context,get_cred->server,strdup(realm));
+        status = krb5_set_principal_realm(bsd_context, get_cred->server,
+                                         realm);
+       if (status) {
+         fprintf(stderr, "kcmd: krb5_set_principal_realm failed %s\n", 
+                 error_message(status));
+         return(-1);
+       }
     }
     if (fd2p == 0) {
        write(s, "", 1);