From fd8a3200e4b581219fa4ac29650c416204d9a771 Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Mar 09 2021 06:18:53 +0000 Subject: Low: scheduler: warn if node state has no ID or uname This should be possible only if someone manually mis-edits the CIB, but that case does merit a warning, and we should bail early if it happens (previously, the right thing would eventually be done anyway, but log messages using a NULL could theoretically cause a crash). --- diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c index 2471bf0..0b4e0cd 100644 --- a/lib/pengine/unpack.c +++ b/lib/pengine/unpack.c @@ -1041,11 +1041,15 @@ unpack_node_loop(xmlNode * status, bool fence, pe_working_set_t * data_set) state != NULL; state = crm_next_same_xml(state)) { const char *id = ID(state); - const char *uname = NULL; + const char *uname = crm_element_value(state, XML_ATTR_UNAME); pe_node_t *this_node = NULL; bool process = FALSE; - uname = crm_element_value(state, XML_ATTR_UNAME); + if ((id == NULL) || (uname == NULL)) { + // Warning already logged in first pass through status section + continue; + } + this_node = pe_find_node_any(data_set->nodes, id, uname); if (this_node == NULL) { @@ -1150,19 +1154,27 @@ unpack_status(xmlNode * status, pe_working_set_t * data_set) const char *resource_discovery_enabled = NULL; id = crm_element_value(state, XML_ATTR_ID); - uname = crm_element_value(state, XML_ATTR_UNAME); - this_node = pe_find_node_any(data_set->nodes, id, uname); + if (id == NULL) { + crm_warn("Ignoring malformed " XML_CIB_TAG_STATE + " entry without " XML_ATTR_ID); + continue; + } + uname = crm_element_value(state, XML_ATTR_UNAME); if (uname == NULL) { - /* error */ + crm_warn("Ignoring malformed " XML_CIB_TAG_STATE + " entry without " XML_ATTR_UNAME); continue; + } - } else if (this_node == NULL) { + this_node = pe_find_node_any(data_set->nodes, id, uname); + if (this_node == NULL) { pcmk__config_warn("Ignoring recorded node status for '%s' " "because no longer in configuration", uname); continue; + } - } else if (pe__is_guest_or_remote_node(this_node)) { + if (pe__is_guest_or_remote_node(this_node)) { /* online state for remote nodes is determined by the * rsc state after all the unpacking is done. we do however * need to mark whether or not the node has been fenced as this plays