Skip to content
Permalink
Browse files

Check strdup return in kadm5_get_config_params()

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 c0af219be218c02e72160ecd0521bc5b9bad546f
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/lib/kadm5/alt_prof.c
@@ -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)
@@ -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;

0 comments on commit c0af219

Please sign in to comment.
You can’t perform that action at this time.