summaryrefslogtreecommitdiff
path: root/mesh
diff options
context:
space:
mode:
authorIsak Westin <isak.westin@loytec.com>2022-09-23 13:31:49 +0200
committerBrian Gix <brian.gix@intel.com>2022-09-23 10:06:37 -0700
commit95d9dc6764fc3859af9528c222eef95e843a9cbc (patch)
treed069a674528202b80951bf983452d13be97e791d /mesh
parent32d866b4df928aa1d7785da7f83d089f64d42797 (diff)
downloadbluez-95d9dc6764fc3859af9528c222eef95e843a9cbc.tar.gz
mesh: Reply error if appkey added for wrong netkey
If a known appkey is added for a different netkey, the status reply should be Invalid NetKey.
Diffstat (limited to 'mesh')
-rw-r--r--mesh/appkey.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mesh/appkey.c b/mesh/appkey.c
index 52fed8c31..f31d81942 100644
--- a/mesh/appkey.c
+++ b/mesh/appkey.c
@@ -296,7 +296,9 @@ int appkey_key_add(struct mesh_net *net, uint16_t net_idx, uint16_t app_idx,
key = l_queue_find(app_keys, match_key_index, L_UINT_TO_PTR(app_idx));
if (key) {
- if (memcmp(new_key, key->key, 16) == 0)
+ if (key->net_idx != net_idx)
+ return MESH_STATUS_INVALID_NETKEY;
+ else if (memcmp(new_key, key->key, 16) == 0)
return MESH_STATUS_SUCCESS;
else
return MESH_STATUS_IDX_ALREADY_STORED;