* krb524d.c (lookup_service_key): Copy key block and free up keytab entry data
authorKen Raeburn <raeburn@mit.edu>
Thu, 7 Mar 2002 00:54:58 +0000 (00:54 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 7 Mar 2002 00:54:58 +0000 (00:54 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14237 dc483132-0cff-0310-8789-dd5450dbe970

src/krb524/ChangeLog
src/krb524/krb524d.c

index 9240e002e5522c84967d13cca4a586dbd95479cb..28707cc5e2efb84851a1e5df6e9e5e354c912e75 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-06  Ken Raeburn  <raeburn@mit.edu>
+
+       * krb524d.c (lookup_service_key): Copy key block and free up
+       keytab entry data.
+
 2001-12-05  Ezra Peisach  <epeisach@mit.edu>
 
        * krb524d.c (cleanup_and_exit): Call krb5_klog_close().
index d856e122f78f3d20e961826b584dd53ab5bb3044..4d55b88a23241c8c90ed2cfd3e67efedffb2667b 100644 (file)
@@ -421,7 +421,18 @@ krb5_error_code lookup_service_key(context, p, ktype, kvno, key, kvnop)
      if (use_keytab) {
          if ((ret = krb5_kt_get_entry(context, kt, p, kvno, ktype, &entry)))
               return ret;
-         memcpy(key, (char *) &entry.key, sizeof(krb5_keyblock));
+         *key = entry.key;
+         key->contents = malloc(key->length);
+         if (key->contents)
+             memcpy(key->contents, entry.key.contents, key->length);
+         else if (key->length) {
+             /* out of memory? */
+             ret = errno;
+             memset (key, 0, sizeof (*key));
+             return ret;
+         }
+
+         krb5_kt_free_entry(context, &entry);
          return 0;
      } else if (use_master) {
          return kdc_get_server_key(context, p, key, kvnop, ktype, kvno);