From: John Kohl Date: Fri, 18 May 1990 10:44:01 +0000 (+0000) Subject: allocate space for padding X-Git-Tag: krb5-1.0-alpha2~521 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0d860a3117ba632976ddfa270ee1683b77b10e55;p=krb5.git allocate space for padding git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@884 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kdb/encrypt_key.c b/src/lib/kdb/encrypt_key.c index 929c7c061..b60752433 100644 --- a/src/lib/kdb/encrypt_key.c +++ b/src/lib/kdb/encrypt_key.c @@ -37,21 +37,27 @@ krb5_keyblock *out; along with the encrypted key */ krb5_error_code retval; + krb5_octet *tmpcontents; out->keytype = in->keytype; out->length = krb5_encrypt_size(in->length, eblock->crypto_entry); + if (!(tmpcontents = (krb5_octet *)calloc(1, out->length))) + return ENOMEM; + + bcopy((char *) in->contents, (char *)tmpcontents, in->length); out->length += sizeof(out->length); out->contents = (krb5_octet *)malloc(out->length); if (!out->contents) { out->contents = 0; out->length = 0; + xfree(tmpcontents); return ENOMEM; } /* copy in real length */ bcopy((char *)&in->length, (char *)out->contents, sizeof(out->length)); /* and arrange for encrypted key */ if (retval = (*eblock->crypto_entry-> - encrypt_func)((krb5_pointer) in->contents, + encrypt_func)((krb5_pointer) tmpcontents, (krb5_pointer) (((char *) out->contents) + sizeof(out->length)), in->length, eblock, 0)) { @@ -59,5 +65,6 @@ krb5_keyblock *out; out->contents = 0; out->length = 0; } + xfree(tmpcontents); return retval; }