summaryrefslogtreecommitdiff
path: root/mesh/manager.c
diff options
context:
space:
mode:
authorMichaƂ Lowas-Rzechonek <michal.lowas-rzechonek@silvair.com>2019-07-19 14:15:59 +0200
committerBrian Gix <brian.gix@intel.com>2019-07-19 12:25:53 -0700
commit79bf51dbb50ab9a10a42fcc51e23be92e2441508 (patch)
treec5266dac42d3325be0076d0f0ea490cf6e388018 /mesh/manager.c
parent060b3439f0c147309e097914df1ca351541b0495 (diff)
downloadbluez-79bf51dbb50ab9a10a42fcc51e23be92e2441508.tar.gz
mesh: Check address range passed to ImportRemoteNode
+changed "not authorized" error to "invalid args" when managing device key for local address range
Diffstat (limited to 'mesh/manager.c')
-rw-r--r--mesh/manager.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/mesh/manager.c b/mesh/manager.c
index 77d7b7516..cf4782c45 100644
--- a/mesh/manager.c
+++ b/mesh/manager.c
@@ -282,6 +282,7 @@ static struct l_dbus_message *import_node_call(struct l_dbus *dbus,
void *user_data)
{
struct mesh_node *node = user_data;
+ struct mesh_net *net = node_get_net(node);
struct l_dbus_message_iter iter_key;
uint16_t primary;
uint8_t num_ele;
@@ -297,6 +298,10 @@ static struct l_dbus_message *import_node_call(struct l_dbus *dbus,
return dbus_error(msg, MESH_ERROR_INVALID_ARGS,
"Bad device key");
+ if (mesh_net_is_local_address(net, primary, num_ele))
+ return dbus_error(msg, MESH_ERROR_INVALID_ARGS,
+ "Cannot overwrite local device key");
+
if (!keyring_put_remote_dev_key(node, primary, num_ele, key))
return dbus_error(msg, MESH_ERROR_FAILED, NULL);
@@ -308,12 +313,17 @@ static struct l_dbus_message *delete_node_call(struct l_dbus *dbus,
void *user_data)
{
struct mesh_node *node = user_data;
+ struct mesh_net *net = node_get_net(node);
uint16_t primary;
uint8_t num_ele;
if (!l_dbus_message_get_arguments(msg, "qy", &primary, &num_ele))
return dbus_error(msg, MESH_ERROR_INVALID_ARGS, NULL);
+ if (mesh_net_is_local_address(net, primary, num_ele))
+ return dbus_error(msg, MESH_ERROR_INVALID_ARGS,
+ "Cannot remove local device key");
+
keyring_del_remote_dev_key(node, primary, num_ele);
return l_dbus_message_new_method_return(msg);