From: Paul Park Date: Tue, 8 Aug 1995 22:02:01 +0000 (+0000) Subject: Fix key merging logic and allow multiple key/salt strings to be parsed X-Git-Tag: krb5-1.0-beta6~1361 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f099e506f2a35b556166e2282be98401e3e402a5;p=krb5.git Fix key merging logic and allow multiple key/salt strings to be parsed git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6465 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/v5server/admin.c b/src/kadmin/v5server/admin.c index b46d80651..5d8dee3f4 100644 --- a/src/kadmin/v5server/admin.c +++ b/src/kadmin/v5server/admin.c @@ -151,10 +151,11 @@ admin_merge_keys(kcontext, dbentp, unique, krb5_key_data *kp1, *kp2; keylist = (krb5_key_data *) NULL; + kret = 0; + numout = 0; if ((keylist = (krb5_key_data *) malloc(sizeof(krb5_key_data) * (nkeys1+nkeys2)))) { memset(keylist, 0, sizeof(krb5_key_data) * (nkeys1+nkeys2)); - numout = 0; if (!unique) { /* The easy case */ /* @@ -281,7 +282,12 @@ admin_merge_keys(kcontext, dbentp, unique, *nkeysout = numout; } else { - free(keylist); + if (keylist) { + if (numout) + key_free_key_data(keylist, numout); + else + free(keylist); + } } return(kret); } @@ -744,6 +750,8 @@ admin_add_modify(kcontext, debug_level, ticket, nargs, arglist, ((should_exist) ? &new_dbentry : &cur_dbentry), 1); + if (should_exist) + principal = (krb5_principal) NULL; } else { /* Database entry failed or yielded unexpected results */ @@ -772,8 +780,9 @@ admin_add_modify(kcontext, debug_level, ticket, nargs, arglist, } } - /* Clean up from krb5_parse_name */ - krb5_free_principal(kcontext, principal); + /* Clean up from krb5_parse_name (If left over) */ + if (principal) + krb5_free_principal(kcontext, principal); } else { /* Principal name parse failed */ @@ -1053,12 +1062,13 @@ admin_keysalt_parse(kcontext, debug_level, nents, entries, dups, int i,j; char *kvnop; int ncolon; - krb5_int32 nparsed; + krb5_int32 nparsed, onparsed; DPRINT(DEBUG_CALLS, debug_level, ("* admin_keysalt_parse()\n")); retval = 0; ndone = 0; keysalts = (krb5_key_salt_tuple *) NULL; + nparsed = 0; if (kvnolist = (krb5_int32 *) malloc(nents * sizeof(krb5_int32))) { for (i=0; iprinc; /* Needed for salts in string2key */ if (keyectomy) { count = dbentp->n_key_data; for (i=0; i