diff mbox series

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

Message ID VI1PR09MB423909FF18D8749A57DA443FE34F9@VI1PR09MB4239.eurprd09.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series Mesh model publication fixes according to mesh profile | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch warning [BlueZ,2/3] mesh: Do not accept publication for unbound appkey WARNING:LONG_LINE: line length of 121 exceeds 80 columns #112: FILE: mesh/model.c:1067: + !has_binding(mod->bindings, idx)) /github/workspace/src/12983376.patch total: 0 errors, 1 warnings, 9 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/12983376.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/gitlint success Gitlint PASS

Commit Message

Isak Westin Sept. 21, 2022, 8:39 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..46ead30ac 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;
 
 	/*