From: Ken Raeburn Date: Thu, 7 Mar 2002 00:54:58 +0000 (+0000) Subject: * krb524d.c (lookup_service_key): Copy key block and free up keytab entry data X-Git-Tag: krb5-1.3-alpha1~853 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b0a741a12d8813ed853301861bdc7237bd8fc51f;p=krb5.git * krb524d.c (lookup_service_key): Copy key block and free up keytab entry data git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14237 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/krb524/ChangeLog b/src/krb524/ChangeLog index 9240e002e..28707cc5e 100644 --- a/src/krb524/ChangeLog +++ b/src/krb524/ChangeLog @@ -1,3 +1,8 @@ +2002-03-06 Ken Raeburn + + * krb524d.c (lookup_service_key): Copy key block and free up + keytab entry data. + 2001-12-05 Ezra Peisach * krb524d.c (cleanup_and_exit): Call krb5_klog_close(). diff --git a/src/krb524/krb524d.c b/src/krb524/krb524d.c index d856e122f..4d55b88a2 100644 --- a/src/krb524/krb524d.c +++ b/src/krb524/krb524d.c @@ -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);