From 800e448aeb86acb06f714027fe70b5af9edfc8b2 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 1 Nov 2018 11:41:41 +0100 Subject: [PATCH] ipadb_mspac_get_trusted_domains: NULL ptr deref Fix potential NULL pointer deref in ipadb_mspac_get_trusted_domains(). In theory, dn could be empty and rdn NULL. The man page for ldap_str2dn() does not guarantee that it returns a non-empty result. See: https://pagure.io/freeipa/issue/7738 Signed-off-by: Christian Heimes Reviewed-By: Alexander Bokovoy --- daemons/ipa-kdb/ipa_kdb_mspac.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemons/ipa-kdb/ipa_kdb_mspac.c b/daemons/ipa-kdb/ipa_kdb_mspac.c index 11e036986..329a5c115 100644 --- a/daemons/ipa-kdb/ipa_kdb_mspac.c +++ b/daemons/ipa-kdb/ipa_kdb_mspac.c @@ -2586,6 +2586,12 @@ krb5_error_code ipadb_mspac_get_trusted_domains(struct ipadb_context *ipactx) } /* We should have a single AVA in the domain RDN */ + if (rdn == NULL) { + ldap_dnfree(dn); + ret = EINVAL; + goto done; + } + t[n].parent_name = strndup(rdn[0]->la_value.bv_val, rdn[0]->la_value.bv_len); ldap_dnfree(dn);