krb5 commit: Check strdup return in kadm5_get_config_params()

Greg Hudson ghudson at mit.edu
Tue Aug 28 14:50:07 EDT 2018


https://github.com/krb5/krb5/commit/c0af219be218c02e72160ecd0521bc5b9bad546f
commit c0af219be218c02e72160ecd0521bc5b9bad546f
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.
    
    ticket: 8727
    tags: pullup
    target_version: 1.16-next
    target_version: 1.15-next

 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