summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2009-02-12 19:43:23 +0000
committerGreg Hudson <ghudson@mit.edu>2009-02-12 19:43:23 +0000
commit0ad5d3008bf4acd29e6d981023bfaca934d00317 (patch)
treea04476d5e569dfbd4266b1a1f411122c6d643e49 /src/lib
parenta1396b8ca353078a496f124f2bbb08620ef3089d (diff)
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
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/krb5/krb/gen_subkey.c22
1 files 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