@cryptotaxi247 / netdata-1 / commits / 2e43085c4

Fixes coverity errors in ACLK (#11322)

Fixes CID371885 and CID371884

Timotej S committed Jul 8, 2021 at 13:27 UTC 2e43085c41dcb2efa457430f94e6261be13cffc3
2 files changed +27 -3
aclk/aclk.c
+7 -1
@@ -972,7 +972,12 @@ void ng_aclk_host_state_update(RRDHOST *host, int cmd)
972
973 void aclk_send_node_instances()
974 {
975 - struct node_instance_list *list = get_node_list();
975 + struct node_instance_list *list_head = get_node_list();
976 + struct node_instance_list *list = list_head;
977 + if (unlikely(!list)) {
978 + error_report("Failure to get_node_list from DB!");
979 + return;
980 + }
981 while (!uuid_is_null(list->host_id)) {
982 if (!uuid_is_null(list->node_id)) {
983 aclk_query_t query = aclk_query_new(NODE_STATE_UPDATE);
@@ -1001,4 +1006,5 @@ void aclk_send_node_instances()
1006
1007 list++;
1008 }
1009 + freez(list_head);
1010 }
aclk/aclk_rx_msgs.c
+20 -2
@@ -270,10 +270,28 @@ void aclk_handle_new_cloud_msg(const char *message_type, const char *msg, size_t
270 }
271 if (!strcmp(message_type, "CreateNodeInstanceResult")) {
272 node_instance_creation_result_t res = parse_create_node_instance_result(msg, msg_len);
273 + if (!res.machine_guid || !res.node_id) {
274 + error_report("Error parsing CreateNodeInstanceResult");
275 + freez(res.machine_guid);
276 + freez(res.node_id);
277 + return;
278 + }
279 +
280 debug(D_ACLK, "CreateNodeInstanceResult: guid:%s nodeid:%s", res.machine_guid, res.node_id);
281 +
282 uuid_t host_id, node_id;
275 - uuid_parse(res.machine_guid, host_id);
276 - uuid_parse(res.node_id, node_id);
283 + if (uuid_parse(res.machine_guid, host_id)) {
284 + error("Error parsing machine_guid provided by CreateNodeInstanceResult");
285 + freez(res.machine_guid);
286 + freez(res.node_id);
287 + return;
288 + }
289 + if (uuid_parse(res.node_id, node_id)) {
290 + error("Error parsing node_id provided by CreateNodeInstanceResult");
291 + freez(res.machine_guid);
292 + freez(res.node_id);
293 + return;
294 + }
295 update_node_id(&host_id, &node_id);
296
297 aclk_query_t query = aclk_query_new(NODE_STATE_UPDATE);