the attached patch will prevent the crash reported in ticket #5928.

So far I do not understand how this situation can occur, there is no reproducer yet. I do not really like this fix as it hides a probable corrupted data structure and would prefer to find the root cause.

But please review it, so we can commit it if there is no progress on the root cause.


Red Hat GmbH, http://www.de.redhat.com/, Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Michael Cunningham, Michael O'Neill, Eric 

>From a3c20fb375da1d0c663d587bd25114e131874050 Mon Sep 17 00:00:00 2001
From: Ludwig Krispenz <lkris...@redhat.com>
Date: Fri, 10 Jun 2016 10:48:04 +0200
Subject: [PATCH] avoid crash in topology plugin when host list contains host
 with no hostname: ticket #5928

 daemons/ipa-slapi-plugins/topology/topology_cfg.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/daemons/ipa-slapi-plugins/topology/topology_cfg.c b/daemons/ipa-slapi-plugins/topology/topology_cfg.c
index 3ca61a8ea7c463c45f3dbf2e13a9790c5079e2d7..2248269fdfeb1d1bc80a31be0241ec8bcee7cf3f 100644
--- a/daemons/ipa-slapi-plugins/topology/topology_cfg.c
+++ b/daemons/ipa-slapi-plugins/topology/topology_cfg.c
@@ -452,6 +452,15 @@ ipa_topo_cfg_host_find(TopoReplica *tconf, char *findhost, int lock)
     if (lock) slapi_lock_mutex(tconf->repl_lock);
     for (host=tconf->hosts;host;host=host->next) {
+        if (host->hostname == NULL) {
+            /* this check is done to avoid a crash,
+             * for which the root cause is not yet known.
+             * Avoid the crash and log an error
+             */
+            slapi_log_error(SLAPI_LOG_PLUGIN, IPA_TOPO_PLUGIN_SUBSYSTEM,
+                            "ipa_topo_cfg_host_find: found a NULL hostname in host list\n");
+            continue;
+        }
         if (!strcasecmp(host->hostname,findhost)) {

Manage your subscription for the Freeipa-devel mailing list:
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to