mesh: Do not accept publication for unbound appkey
authorIsak Westin <isak.westin@hotmail.com>
Wed, 21 Sep 2022 11:16:29 +0000 (13:16 +0200)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:55 +0000 (14:55 +0530)
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 <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
mesh/model.c

index 82078ed..d48e6ef 100644 (file)
@@ -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;
 
        /*