File pacemaker-lib-memory-allocation-errors.patch of Package pacemaker.3577
commit 02e303ea3ac4a1bef70ad1e79ae402e6ad02ebd3
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Fri Aug 5 10:33:35 2016 -0500
Low: libcib,libfencing,libtransition: handle memory allocation errors without CRM_CHECK()
makes coverity happy
Index: pacemaker/lib/cib/cib_attrs.c
===================================================================
--- pacemaker.orig/lib/cib/cib_attrs.c
+++ pacemaker/lib/cib/cib_attrs.c
@@ -93,7 +93,10 @@ find_nvpair_attr_delegate(cib_t * the_ci
}
xpath_string = calloc(1, xpath_max);
- CRM_CHECK(xpath_string != NULL, return -ENOMEM);
+ if (xpath_string == NULL) {
+ crm_perror(LOG_CRIT, "Could not create xpath");
+ return -ENOMEM;
+ }
attr_snprintf(xpath_string, offset, xpath_max, "%.128s", get_object_path(section));
Index: pacemaker/lib/fencing/st_client.c
===================================================================
--- pacemaker.orig/lib/fencing/st_client.c
+++ pacemaker/lib/fencing/st_client.c
@@ -302,6 +302,11 @@ create_level_registration_xml(const char
crm_trace("Adding %s (%dc) at offset %d", device_list->value, adding, len);
list = realloc_safe(list, len + adding + 1); /* +1 EOS */
+ if (list == NULL) {
+ crm_perror(LOG_CRIT, "Could not create device list");
+ free_xml(data);
+ return NULL;
+ }
sprintf(list + len, "%s%s", len?",":"", device_list->value);
len += adding;
}
Index: pacemaker/lib/transition/unpack.c
===================================================================
--- pacemaker.orig/lib/transition/unpack.c
+++ pacemaker/lib/transition/unpack.c
@@ -41,7 +41,11 @@ unpack_action(synapse_t * parent, xmlNod
}
action = calloc(1, sizeof(crm_action_t));
- CRM_CHECK(action != NULL, return NULL);
+ if (action == NULL) {
+ crm_perror(LOG_CRIT, "Cannot unpack action");
+ crm_log_xml_trace(xml_action, "Lost action");
+ return NULL;
+ }
action->id = crm_parse_int(value, NULL);
action->type = action_type_rsc;