From 0694a632a5e8d34fe53369a307b59a3929ce179e Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 19 Jul 2019 21:14:58 +0200 Subject: [PATCH] mesh: check netkey index if mesh proxy server not suppoted --- src/mesh/mesh_configuration_server.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/mesh/mesh_configuration_server.c b/src/mesh/mesh_configuration_server.c index fc1342e24..a81e5c286 100644 --- a/src/mesh/mesh_configuration_server.c +++ b/src/mesh/mesh_configuration_server.c @@ -2101,6 +2101,12 @@ static void config_node_identity_get_handler(mesh_model_t *mesh_model, mesh_pdu_ uint8_t status = MESH_FOUNDATION_STATUS_SUCCESS; #ifdef ENABLE_MESH_PROXY_SERVER status = mesh_proxy_get_advertising_with_node_id_status(netkey_index, &node_identity_state); +#else + mesh_subnet_t * network_key = mesh_subnet_get_by_netkey_index(netkey_index); + if (network_key == NULL){ + status = MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX; + node_identity_state = MESH_NODE_IDENTITY_STATE_ADVERTISING_STOPPED; + } #endif config_node_identity_status(mesh_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, netkey_index, node_identity_state); @@ -2113,11 +2119,22 @@ static void config_node_identity_set_handler(mesh_model_t *mesh_model, mesh_pdu_ uint16_t netkey_index = mesh_access_parser_get_u16(&parser); mesh_node_identity_state_t node_identity_state = (mesh_node_identity_state_t) mesh_access_parser_get_u8(&parser); + // ignore invalid state + if (node_identity_state >= MESH_NODE_IDENTITY_STATE_ADVERTISING_NOT_SUPPORTED) { + mesh_access_message_processed(pdu); + return; + } + uint8_t status = MESH_FOUNDATION_STATUS_SUCCESS; #ifdef ENABLE_MESH_PROXY_SERVER status = mesh_proxy_set_advertising_with_node_id(netkey_index, node_identity_state); +#else + mesh_subnet_t * network_key = mesh_subnet_get_by_netkey_index(netkey_index); + if (network_key == NULL){ + status = MESH_FOUNDATION_STATUS_INVALID_NETKEY_INDEX; + } #endif - + config_node_identity_status(mesh_model, mesh_pdu_netkey_index(pdu), mesh_pdu_src(pdu), status, netkey_index, node_identity_state); mesh_access_message_processed(pdu);