Skip to content

Commit

Permalink
Check strdup return in kadm5_get_config_params()
Browse files Browse the repository at this point in the history
When copying the realm string, if strdup() returns NULL, fail out with
ENOMEM instead of pretending the realm wasn't specified.  When copying
KRB5_DEFAULT_SUPPORTED_ENCTYPES, if strdup() returns NULL, fail out
with ENOMEM instead of crashing.  Reported by Bean Zhang.

ticket: 8727
tags: pullup
target_version: 1.16-next
target_version: 1.15-next
  • Loading branch information
greghudson committed Aug 28, 2018
1 parent 405dd1f commit c0af219
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib/kadm5/alt_prof.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,11 @@ krb5_error_code kadm5_get_config_params(krb5_context context,

if (params_in->mask & KADM5_CONFIG_REALM) {
lrealm = params.realm = strdup(params_in->realm);
if (params.realm != NULL)
params.mask |= KADM5_CONFIG_REALM;
if (params.realm == NULL) {
ret = ENOMEM;
goto cleanup;
}
params.mask |= KADM5_CONFIG_REALM;
} else {
ret = krb5_get_default_realm(context, &lrealm);
if (ret)
Expand Down Expand Up @@ -730,6 +733,10 @@ krb5_error_code kadm5_get_config_params(krb5_context context,
krb5_aprof_get_string(aprofile, hierarchy, TRUE, &svalue);
if (svalue == NULL)
svalue = strdup(KRB5_DEFAULT_SUPPORTED_ENCTYPES);
if (svalue == NULL) {
ret = ENOMEM;
goto cleanup;
}

params.keysalts = NULL;
params.num_keysalts = 0;
Expand Down

0 comments on commit c0af219

Please sign in to comment.