From e11954c5838da3ad954ad331680277398a148609 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Fri, 4 Oct 1996 12:41:52 +0000 Subject: [PATCH] * svr_principal.c (kadm5_get_principal): Do not assume malloc(0) returns non-NULL. [krb5-admin/46] git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9143 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/kadm5/srv/ChangeLog | 5 +++++ src/lib/kadm5/srv/svr_principal.c | 16 ++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/lib/kadm5/srv/ChangeLog b/src/lib/kadm5/srv/ChangeLog index dd9f678b8..50923c177 100644 --- a/src/lib/kadm5/srv/ChangeLog +++ b/src/lib/kadm5/srv/ChangeLog @@ -1,3 +1,8 @@ +Fri Oct 4 08:40:21 1996 Ezra Peisach + + * svr_principal.c (kadm5_get_principal): Do not assume malloc(0) + returns non-NULL. [krb5-admin/46] + Fri Aug 2 14:07:31 1996 Barry Jaspan * svr_principal.c: remove krb5_free_keyblock_contents (moved to diff --git a/src/lib/kadm5/srv/svr_principal.c b/src/lib/kadm5/srv/svr_principal.c index 082f98c0b..5bb1cbbbb 100644 --- a/src/lib/kadm5/srv/svr_principal.c +++ b/src/lib/kadm5/srv/svr_principal.c @@ -738,12 +738,16 @@ kadm5_get_principal(void *server_handle, krb5_principal principal, } if (mask & KADM5_KEY_DATA) { entry->n_key_data = kdb.n_key_data; - entry->key_data = (krb5_key_data *) - malloc(entry->n_key_data*sizeof(krb5_key_data)); - if (entry->key_data == NULL) { - ret = ENOMEM; - goto done; - } + if(entry->n_key_data) { + entry->key_data = (krb5_key_data *) + malloc(entry->n_key_data*sizeof(krb5_key_data)); + if (entry->key_data == NULL) { + ret = ENOMEM; + goto done; + } + } else + entry->key_data = NULL; + for (i = 0; i < entry->n_key_data; i++) if (ret = krb5_copy_key_data_contents(handle->context, &kdb.key_data[i], -- 2.26.2