krb5 commit [krb5-1.16]: Check strdup return in kadm5_get_config_params()
Greg Hudson
ghudson at mit.edu
Tue Oct 30 12:25:44 EDT 2018
https://github.com/krb5/krb5/commit/06e5b5d5a032e9dfedcd19df54f16a4ce802bcbe
commit 06e5b5d5a032e9dfedcd19df54f16a4ce802bcbe
Author: Greg Hudson <ghudson at mit.edu>
Date: Mon Aug 27 21:10:53 2018 -0400
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.
(cherry picked from commit c0af219be218c02e72160ecd0521bc5b9bad546f)
ticket: 8727
version_fixed: 1.16.2
src/lib/kadm5/alt_prof.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/lib/kadm5/alt_prof.c b/src/lib/kadm5/alt_prof.c
index ec6290e..e2d8f77 100644
--- a/src/lib/kadm5/alt_prof.c
+++ b/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;
More information about the cvs-krb5
mailing list