File pacemaker-libcrmcluster-crm_strdup_printf-instead-of-calloc.patch of Package pacemaker.8397
commit a3c5044578be55f2b9fabf1f85d38f3ad4b1329a
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Tue Nov 28 08:58:23 2017 -0600
Low: libcrmcluster: use crm_strdup_printf() instead of calloc()
simplifies code, asserts on error, and allocates proper amount of memory
Index: pacemaker-1.1.16+20170320.77ea74d/lib/cluster/cluster.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/lib/cluster/cluster.c
+++ pacemaker-1.1.16+20170320.77ea74d/lib/cluster/cluster.c
@@ -110,16 +110,7 @@ get_corosync_uuid(crm_node_t *node)
} else if (!uname_is_uuid() && is_corosync_cluster()) {
if (node->id > 0) {
- int len = 32;
- char *buffer = NULL;
-
- buffer = calloc(1, (len + 1));
- if (buffer != NULL) {
- snprintf(buffer, len, "%u", node->id);
- }
-
- return buffer;
-
+ return crm_strdup_printf("%u", node->id);
} else {
crm_info("Node %s is not yet known by corosync", node->uname);
}