diff options
author | Greg Hudson <ghudson@mit.edu> | 2016-05-16 22:54:06 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2016-05-26 11:20:05 -0400 |
commit | 03d34fcfa329fbc2f686a0b34e2731e37f483a34 (patch) | |
tree | e5dcda351a26b5637e6f2299d12d36747a8ea993 /src/lib/kdb | |
parent | 2ac75e548afadde4f87f20fcc1ee1472cdac3fed (diff) | |
download | krb5-03d34fcfa329fbc2f686a0b34e2731e37f483a34.zip krb5-03d34fcfa329fbc2f686a0b34e2731e37f483a34.tar.gz krb5-03d34fcfa329fbc2f686a0b34e2731e37f483a34.tar.bz2 |
Use library malloc for principal, policy entries
Alter the KDB module contract to require that KDB modules use an
allocator compatible with the malloc() seen by libkrb5 and libkdb5.
Change krb5_db_alloc() and krb5_db_free() to provide access to this
allocator. Remove free_principal, free_policy, alloc, and free from
the KDB interface and from all in-tree KDB modules.
ticket: 8414 (new)
Diffstat (limited to 'src/lib/kdb')
-rw-r--r-- | src/lib/kdb/kdb5.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c index 168a25d..20e8698 100644 --- a/src/lib/kdb/kdb5.c +++ b/src/lib/kdb/kdb5.c @@ -766,16 +766,32 @@ krb5_db_get_principal(krb5_context kcontext, krb5_const_principal search_for, return 0; } +static void +free_tl_data(krb5_tl_data *list) +{ + krb5_tl_data *next; + + for (; list != NULL; list = next) { + next = list->tl_data_next; + free(list->tl_data_contents); + free(list); + } +} + void krb5_db_free_principal(krb5_context kcontext, krb5_db_entry *entry) { - krb5_error_code status = 0; - kdb_vftabl *v; + int i; - status = get_vftabl(kcontext, &v); - if (status) + if (entry == NULL) return; - v->free_principal(kcontext, entry); + free(entry->e_data); + krb5_free_principal(kcontext, entry->princ); + free_tl_data(entry->tl_data); + for (i = 0; i < entry->n_key_data; i++) + krb5_dbe_free_key_data_contents(kcontext, &entry->key_data[i]); + free(entry->key_data); + free(entry); } static void @@ -1332,25 +1348,13 @@ krb5_dbe_find_mkey(krb5_context context, krb5_db_entry *entry, void * krb5_db_alloc(krb5_context kcontext, void *ptr, size_t size) { - krb5_error_code status; - kdb_vftabl *v; - - status = get_vftabl(kcontext, &v); - if (status) - return NULL; - return v->alloc(kcontext, ptr, size); + return realloc(ptr, size); } void krb5_db_free(krb5_context kcontext, void *ptr) { - krb5_error_code status; - kdb_vftabl *v; - - status = get_vftabl(kcontext, &v); - if (status) - return; - v->free(kcontext, ptr); + free(ptr); } /* has to be modified */ @@ -2441,13 +2445,12 @@ krb5_db_delete_policy(krb5_context kcontext, char *policy) void krb5_db_free_policy(krb5_context kcontext, osa_policy_ent_t policy) { - krb5_error_code status = 0; - kdb_vftabl *v; - - status = get_vftabl(kcontext, &v); - if (status || v->free_policy == NULL) + if (policy == NULL) return; - v->free_policy(kcontext, policy); + free(policy->name); + free(policy->allowed_keysalts); + free_tl_data(policy->tl_data); + free(policy); } krb5_error_code |