File pacemaker-lrmd-libcluster-g_hash_table_foreach-null-table.patch of Package pacemaker.14737
commit 8cf6dfeea1908aa88f9916dc2ce3b910dedb4aae
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Tue Jul 26 11:16:28 2016 -0500
Fix: lrmd,libcluster: ensure g_hash_table_foreach() is never passed a null table
diff --git a/lib/cluster/membership.c b/lib/cluster/membership.c
index 408aa6e..cc62fb1 100644
--- a/lib/cluster/membership.c
+++ b/lib/cluster/membership.c
@@ -256,6 +256,8 @@ crm_remote_peer_cache_refresh(xmlNode *cib)
{
struct refresh_data data;
+ crm_peer_init();
+
/* First, we mark all existing cache entries as dirty,
* so that later we can remove any that weren't in the CIB.
* We don't empty the cache, because we need to detect changes in state.
diff --git a/lrmd/lrmd.c b/lrmd/lrmd.c
index 0c40a38..b43a226 100644
--- a/lrmd/lrmd.c
+++ b/lrmd/lrmd.c
@@ -660,7 +660,7 @@ send_cmd_complete_notify(lrmd_cmd_t * cmd)
if (client) {
send_client_notify(client->id, client, notify);
}
- } else {
+ } else if (client_connections != NULL) {
g_hash_table_foreach(client_connections, send_client_notify, notify);
}
@@ -670,24 +670,26 @@ send_cmd_complete_notify(lrmd_cmd_t * cmd)
static void
send_generic_notify(int rc, xmlNode * request)
{
- int call_id = 0;
- xmlNode *notify = NULL;
- xmlNode *rsc_xml = get_xpath_object("//" F_LRMD_RSC, request, LOG_ERR);
- const char *rsc_id = crm_element_value(rsc_xml, F_LRMD_RSC_ID);
- const char *op = crm_element_value(request, F_LRMD_OPERATION);
-
- crm_element_value_int(request, F_LRMD_CALLID, &call_id);
-
- notify = create_xml_node(NULL, T_LRMD_NOTIFY);
- crm_xml_add(notify, F_LRMD_ORIGIN, __FUNCTION__);
- crm_xml_add_int(notify, F_LRMD_RC, rc);
- crm_xml_add_int(notify, F_LRMD_CALLID, call_id);
- crm_xml_add(notify, F_LRMD_OPERATION, op);
- crm_xml_add(notify, F_LRMD_RSC_ID, rsc_id);
+ if (client_connections != NULL) {
+ int call_id = 0;
+ xmlNode *notify = NULL;
+ xmlNode *rsc_xml = get_xpath_object("//" F_LRMD_RSC, request, LOG_ERR);
+ const char *rsc_id = crm_element_value(rsc_xml, F_LRMD_RSC_ID);
+ const char *op = crm_element_value(request, F_LRMD_OPERATION);
+
+ crm_element_value_int(request, F_LRMD_CALLID, &call_id);
+
+ notify = create_xml_node(NULL, T_LRMD_NOTIFY);
+ crm_xml_add(notify, F_LRMD_ORIGIN, __FUNCTION__);
+ crm_xml_add_int(notify, F_LRMD_RC, rc);
+ crm_xml_add_int(notify, F_LRMD_CALLID, call_id);
+ crm_xml_add(notify, F_LRMD_OPERATION, op);
+ crm_xml_add(notify, F_LRMD_RSC_ID, rsc_id);
- g_hash_table_foreach(client_connections, send_client_notify, notify);
+ g_hash_table_foreach(client_connections, send_client_notify, notify);
- free_xml(notify);
+ free_xml(notify);
+ }
}
static void