Skip to content

Commit

Permalink
Merge pull request #443 from pwieczorkiewicz/cs_parse_fix
Browse files Browse the repository at this point in the history
client-state: Do not fail on parsing empty origin and uuid (bnc#890084)
  • Loading branch information
wipawel committed Sep 26, 2014
2 parents dd27bd7 + 1386287 commit de1b34b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/client/client_state.c
Expand Up @@ -150,14 +150,14 @@ ni_client_state_control_parse_xml(const xml_node_t *node, ni_client_state_contro

/* <persistent> node is mandatory */
child = xml_node_get_child(parent, NI_CLIENT_STATE_XML_PERSISTENT_NODE);
if (!child || !child->cdata ||
if (!child || ni_string_empty(child->cdata) ||
ni_parse_boolean(child->cdata, &ctrl->persistent)) {
return FALSE;
}

/* <usercontrol> node is mandatory */
child = xml_node_get_child(parent, NI_CLIENT_STATE_XML_USERCONTROL_NODE);
if (!child || !child->cdata ||
if (!child || ni_string_empty(child->cdata) ||
ni_parse_boolean(child->cdata, &ctrl->usercontrol)) {
return FALSE;
}
Expand All @@ -177,20 +177,23 @@ ni_client_state_config_parse_xml(const xml_node_t *node, ni_client_state_config_
if (!(parent = xml_node_get_child(node, NI_CLIENT_STATE_XML_CONFIG_NODE)))
return FALSE;

/* within <config> node <uuid> is mandatory */
/* within <config> node <uuid> is mandatory, yet may be empty */
child = xml_node_get_child(parent, NI_CLIENT_STATE_XML_CONFIG_UUID_NODE);
if (!child || !child->cdata || ni_uuid_parse(&conf->uuid, child->cdata))
if (!child || (child->cdata && ni_uuid_parse(&conf->uuid, child->cdata)))
return FALSE;

/* within <config> node <origin> is mandatory */
/* within <config> node <origin> is mandatory, yet may be empty */
child = xml_node_get_child(parent, NI_CLIENT_STATE_XML_CONFIG_ORIGIN_NODE);
if (!child || !child->cdata)
if (!child)
return FALSE;
ni_string_dup(&conf->origin, child->cdata);

/* within <config> node <owner-uid> is optional */
child = xml_node_get_child(parent, NI_CLIENT_STATE_XML_CONFIG_OWNER_NODE);
if (!child || !child->cdata || ni_parse_uint(child->cdata, &conf->owner, 10))
return FALSE;
if (child && !ni_string_empty(child->cdata)) {
if (ni_parse_uint(child->cdata, &conf->owner, 10))
return FALSE;
}

return TRUE;
}
Expand Down

0 comments on commit de1b34b

Please sign in to comment.