From 0ad5d3008bf4acd29e6d981023bfaca934d00317 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Thu, 12 Feb 2009 19:43:23 +0000 Subject: [PATCH] Make output parameter of krb5_generate_subkey_extended well-defined on error, and reformat function to fit coding standards. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21984 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/gen_subkey.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/lib/krb5/krb/gen_subkey.c b/src/lib/krb5/krb/gen_subkey.c index 601ab739a..501428b1d 100644 --- a/src/lib/krb5/krb/gen_subkey.c +++ b/src/lib/krb5/krb/gen_subkey.c @@ -47,20 +47,28 @@ krb5_generate_subkey_extended(krb5_context context, { krb5_error_code retval; krb5_data seed; + krb5_keyblock *keyblock; + + *subkey = NULL; seed = key2data(*key); - if ((retval = krb5_c_random_add_entropy(context, KRB5_C_RANDSOURCE_TRUSTEDPARTY, &seed))) - return(retval); + retval = krb5_c_random_add_entropy(context, KRB5_C_RANDSOURCE_TRUSTEDPARTY, + &seed); + if (retval) + return retval; - if ((*subkey = (krb5_keyblock *) malloc(sizeof(krb5_keyblock))) == NULL) - return(ENOMEM); + keyblock = malloc(sizeof(krb5_keyblock)); + if (!keyblock) + return ENOMEM; - if ((retval = krb5_c_make_random_key(context, enctype, *subkey))) { + retval = krb5_c_make_random_key(context, enctype, keyblock); + if (retval) { free(*subkey); - return(retval); + return retval; } - return(0); + *subkey = keyblock; + return 0; } krb5_error_code -- 2.26.2