File pacemaker-right-size-for-string-buffer-fake_transition.patch of Package pacemaker.14737
commit 00f214459e587476742eb8367fd47bfc8a5fdc74
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Fri Sep 22 16:37:32 2017 -0500
Low: tools: use right size for string buffer in fake_transition.c
issue found by Jan Pokorný <jpokorny@redhat.com>
diff --git a/tools/fake_transition.c b/tools/fake_transition.c
index bb5c8977b..db0ad1edf 100644
--- a/tools/fake_transition.c
+++ b/tools/fake_transition.c
@@ -184,23 +184,20 @@ static xmlNode *
inject_node_state(cib_t * cib_conn, const char *node, const char *uuid)
{
int rc = pcmk_ok;
- int max = strlen(rsc_template) + strlen(node) + 1;
- char *xpath = NULL;
xmlNode *cib_object = NULL;
-
- xpath = calloc(1, max);
+ char *xpath = crm_strdup_printf(node_template, node);
if (bringing_nodes_online) {
create_node_entry(cib_conn, node);
}
- snprintf(xpath, max, node_template, node);
rc = cib_conn->cmds->query(cib_conn, xpath, &cib_object,
cib_xpath | cib_sync_call | cib_scope_local);
if (cib_object && ID(cib_object) == NULL) {
crm_err("Detected multiple node_state entries for xpath=%s, bailing", xpath);
crm_log_xml_warn(cib_object, "Duplicates");
+ free(xpath);
crm_exit(ENOTUNIQ);
}