diff mbox series

[BlueZ,v2,2/3] mesh: Do not accept publication for unbound appkey

Message ID VI1PR09MB42398AED3429C6F2EFEB5F1BE34F9@VI1PR09MB4239.eurprd09.prod.outlook.com (mailing list archive)
State Accepted
Commit b72edcc5ca6fd0b3728a37cfa2bfbf483953ebba
Headers show
Series [BlueZ,v2,1/3] mesh: Add interface output filter | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS

Commit Message

Isak Westin Sept. 21, 2022, 11:16 a.m. UTC
If a user tries to configure publication of a model with an appkey that
is not bound to that model, an error should be returned.
---
 mesh/model.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/mesh/model.c b/mesh/model.c
index 82078ed85..d48e6ef12 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -1063,7 +1063,8 @@  int mesh_model_pub_set(struct mesh_node *node, uint16_t addr, uint32_t id,
 	if (!mod->pub_enabled || (mod->cbs && !(mod->cbs->pub)))
 		return MESH_STATUS_INVALID_PUB_PARAM;
 
-	if (!appkey_have_key(node_get_net(node), idx))
+	if (!appkey_have_key(node_get_net(node), idx) ||
+			!has_binding(mod->bindings, idx))
 		return MESH_STATUS_INVALID_APPKEY;
 
 	/*