From b0a741a12d8813ed853301861bdc7237bd8fc51f Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 7 Mar 2002 00:54:58 +0000 Subject: [PATCH] * 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 --- src/krb524/ChangeLog | 5 +++++ src/krb524/krb524d.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) 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); -- 2.26.2