krb5 commit [krb5-1.15]: Check strdup return in kadm5_get_config_params()

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/d6ce2d8273bf4b2a51de882866e42d33d1f568ca
commit d6ce2d8273bf4b2a51de882866e42d33d1f568ca
Author: Greg Hudson <[email protected]>
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.15.4

 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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.