From 9af24fa314cbdcdecee344c2caf2b945ae98b34c Mon Sep 17 00:00:00 2001 From: Isak Westin Date: Wed, 21 Sep 2022 13:16:29 +0200 Subject: [PATCH] mesh: Do not accept publication for unbound appkey 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. Signed-off-by: Manika Shrivastava Signed-off-by: Ayush Garg --- mesh/model.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mesh/model.c b/mesh/model.c index 82078ed..d48e6ef 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; /* -- 2.7.4