File pacemaker-crm_resource-restart-segfault.patch of Package pacemaker.3577
commit c71206964491ab4d3e6a98ba92e720be1e0c0a30
Author: Gao,Yan <ygao@suse.com>
Date: Mon Feb 29 18:29:39 2016 +0100
Fix: crm_resource: Prevent segfault when --resource is not correctly supplied for --restart command
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
index f5b63d4..52eb8d2 100644
--- a/tools/crm_resource.c
+++ b/tools/crm_resource.c
@@ -659,7 +659,21 @@ main(int argc, char **argv)
}
} else if (rsc_cmd == 0 && rsc_long_cmd && safe_str_eq(rsc_long_cmd, "restart")) {
- resource_t *rsc = pe_find_resource(data_set.resources, rsc_id);
+ resource_t *rsc = NULL;
+
+ rc = -ENXIO;
+ if (rsc_id == NULL) {
+ CMD_ERR("Must supply a resource id with -r");
+ goto bail;
+ }
+
+ rsc = pe_find_resource(data_set.resources, rsc_id);
+
+ rc = -EINVAL;
+ if (rsc == NULL) {
+ CMD_ERR("Resource '%s' not restarted: unknown", rsc_id);
+ goto bail;
+ }
rc = cli_resource_restart(rsc, host_uname, timeout_ms, cib_conn);