commit 5882024877d6c22f0663160a3f7278a421f31819 Author: Andrew Beekhof Date: Wed Aug 7 09:03:43 2013 +1000 Fix: PE: Gracefully handle bad values for XML_ATTR_TRANSITION_MAGIC (cherry picked from commit 164ca366c14c914794f9230acd7646426641e6b2) diff --git a/lib/common/utils.c b/lib/common/utils.c index 4e18039..7543464 100644 --- a/lib/common/utils.c +++ b/lib/common/utils.c @@ -885,15 +885,13 @@ decode_transition_magic(const char *magic, char **uuid, int *transition_id, int key = calloc(1, strlen(magic) + 1); res = sscanf(magic, "%d:%d;%s", op_status, op_rc, key); if (res != 3) { - crm_crit("Only found %d items in: %s", res, magic); - result = FALSE; - goto bail; + crm_warn("Only found %d items in: '%s'", res, magic); + free(key); + return FALSE; } - CRM_CHECK(decode_transition_key(key, uuid, transition_id, action_id, target_rc), result = FALSE; - goto bail;); + CRM_CHECK(decode_transition_key(key, uuid, transition_id, action_id, target_rc), result = FALSE); - bail: free(key); return result; } diff --git a/lib/pengine/utils.c b/lib/pengine/utils.c index e9997a2..1e827e0 100644 --- a/lib/pengine/utils.c +++ b/lib/pengine/utils.c @@ -1332,11 +1332,12 @@ sort_op_by_callid(gconstpointer a, gconstpointer b) const char *b_magic = crm_element_value_const(xml_b, XML_ATTR_TRANSITION_MAGIC); CRM_CHECK(a_magic != NULL && b_magic != NULL, sort_return(0, "No magic")); - CRM_CHECK(decode_transition_magic(a_magic, &a_uuid, &a_id, &dummy, &dummy, &dummy, &dummy), - sort_return(0, "bad magic a")); - CRM_CHECK(decode_transition_magic(b_magic, &b_uuid, &b_id, &dummy, &dummy, &dummy, &dummy), - sort_return(0, "bad magic b")); - + if(!decode_transition_magic(a_magic, &a_uuid, &a_id, &dummy, &dummy, &dummy, &dummy)) { + sort_return(0, "bad magic a"); + } + if(!decode_transition_magic(b_magic, &b_uuid, &b_id, &dummy, &dummy, &dummy, &dummy)) { + sort_return(0, "bad magic b"); + } /* try and determin the relative age of the operation... * some pending operations (ie. a start) may have been supuerceeded * by a subsequent stop