File pacemaker-lrmd-libcluster-g_hash_table_foreach-null-table.patch of Package pacemaker.3577

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

Index: pacemaker/lib/cluster/membership.c
===================================================================
--- pacemaker.orig/lib/cluster/membership.c
+++ pacemaker/lib/cluster/membership.c
@@ -126,6 +126,8 @@ remote_cache_refresh_helper(xmlNode *cib
  */
 void crm_remote_peer_cache_refresh(xmlNode *cib)
 {
+    crm_peer_init();
+
     g_hash_table_remove_all(crm_remote_peer_cache);
 
     /* remote nodes associated with a cluster resource */
Index: pacemaker/lrmd/lrmd.c
===================================================================
--- pacemaker.orig/lrmd/lrmd.c
+++ pacemaker/lrmd/lrmd.c
@@ -541,7 +541,7 @@ send_cmd_complete_notify(lrmd_cmd_t * cm
         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);
     }
 
@@ -551,24 +551,26 @@ send_cmd_complete_notify(lrmd_cmd_t * cm
 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
openSUSE Build Service is sponsored by