diff options
| author | Greg Hudson <ghudson@mit.edu> | 2013-07-15 12:20:26 -0400 |
|---|---|---|
| committer | Greg Hudson <ghudson@mit.edu> | 2013-07-15 12:20:26 -0400 |
| commit | d9457b501cbab535e5968dbdf195ca334b9fa555 (patch) | |
| tree | c9ff36befead0c3530f82b1574ffeafb7333af94 /src/plugins | |
| parent | 4365d313c6109988268b746bcaf1c08f7b7a593c (diff) | |
| download | krb5-d9457b501cbab535e5968dbdf195ca334b9fa555.tar.gz krb5-d9457b501cbab535e5968dbdf195ca334b9fa555.tar.xz krb5-d9457b501cbab535e5968dbdf195ca334b9fa555.zip | |
Avoid allocating zero key_data structures
When we allocate space for an array of key_data structures, make sure
we allocate at least one, so we don't spuriously fail on platforms
where malloc(0) returns NULL. Where we use malloc, use k5calloc
instead. Where we use krb5_db_alloc or realloc, just allocate an
extra entry.
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c index bcdc1dc473..c30599e721 100644 --- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c +++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c @@ -1380,7 +1380,8 @@ krb5_decode_krbsecretkey(krb5_context context, krb5_db_entry *entries, } noofkeys += n_kd; tmp = key_data; - key_data = realloc (key_data, noofkeys * sizeof (krb5_key_data)); + /* Allocate an extra key data to avoid allocating zero bytes. */ + key_data = realloc(key_data, (noofkeys + 1) * sizeof (krb5_key_data)); if (key_data == NULL) { key_data = tmp; st = ENOMEM; |
