|
|
ed0026 |
commit d4cf7c479c30b4543db45fcce9bf69352b77f85c
|
|
|
ed0026 |
Author: Andrew Beekhof <andrew@beekhof.net>
|
|
|
ed0026 |
Date: Tue Aug 6 20:36:14 2013 +1000
|
|
|
ed0026 |
|
|
|
ed0026 |
Fix: Prevent use-of-NULL when ping resources do not define a host list
|
|
|
ed0026 |
|
|
|
ed0026 |
(cherry picked from commit 7f76afac965afa209e570deac612c696fdcaddb2)
|
|
|
ed0026 |
|
|
|
ed0026 |
diff --git a/tools/crm_mon.c b/tools/crm_mon.c
|
|
|
ed0026 |
index 9387b46..9d68237 100644
|
|
|
ed0026 |
--- a/tools/crm_mon.c
|
|
|
ed0026 |
+++ b/tools/crm_mon.c
|
|
|
ed0026 |
@@ -973,7 +973,6 @@ print_attr_msg(node_t * node, GListPtr rsc_list, const char *attrname, const cha
|
|
|
ed0026 |
if (safe_str_eq(type, "ping") || safe_str_eq(type, "pingd")) {
|
|
|
ed0026 |
const char *name = "pingd";
|
|
|
ed0026 |
const char *multiplier = NULL;
|
|
|
ed0026 |
- char **host_list = NULL;
|
|
|
ed0026 |
int host_list_num = 0;
|
|
|
ed0026 |
int expected_score = 0;
|
|
|
ed0026 |
|
|
|
ed0026 |
@@ -984,11 +983,15 @@ print_attr_msg(node_t * node, GListPtr rsc_list, const char *attrname, const cha
|
|
|
ed0026 |
/* To identify the resource with the attribute name. */
|
|
|
ed0026 |
if (safe_str_eq(name, attrname)) {
|
|
|
ed0026 |
int value = crm_parse_int(attrvalue, "0");
|
|
|
ed0026 |
+ const char *hosts = g_hash_table_lookup(rsc->parameters, "host_list");
|
|
|
ed0026 |
|
|
|
ed0026 |
multiplier = g_hash_table_lookup(rsc->parameters, "multiplier");
|
|
|
ed0026 |
- host_list = g_strsplit(g_hash_table_lookup(rsc->parameters, "host_list"), " ", 0);
|
|
|
ed0026 |
- host_list_num = g_strv_length(host_list);
|
|
|
ed0026 |
- g_strfreev(host_list);
|
|
|
ed0026 |
+ if(hosts) {
|
|
|
ed0026 |
+ char **host_list = g_strsplit(hosts, " ", 0);
|
|
|
ed0026 |
+ host_list_num = g_strv_length(host_list);
|
|
|
ed0026 |
+ g_strfreev(host_list);
|
|
|
ed0026 |
+ }
|
|
|
ed0026 |
+
|
|
|
ed0026 |
/* pingd multiplier is the same as the default value. */
|
|
|
ed0026 |
expected_score = host_list_num * crm_parse_int(multiplier, "1");
|
|
|
ed0026 |
|