From: Inga Stotland <inga.stotland@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: Inga Stotland <inga.stotland@intel.com>
Subject: [PATCH BlueZ] mesh: validate configuration target
Date: Mon, 20 Nov 2017 23:08:48 -0800 [thread overview]
Message-ID: <20171121070848.7305-1-inga.stotland@intel.com> (raw)
Require obtaining node composition prior to sending configuration
commands that assume knowledge about the node's element/model layout.
---
mesh/config-client.c | 31 +++++++++++++++++++++++++------
1 file changed, 25 insertions(+), 6 deletions(-)
diff --git a/mesh/config-client.c b/mesh/config-client.c
index d80f784e6..782781602 100644
--- a/mesh/config-client.c
+++ b/mesh/config-client.c
@@ -461,16 +461,37 @@ static void cmd_del_app_key(const char *args)
cmd_app_key(args, OP_APPKEY_DELETE);
}
+static bool verify_config_target(uint32_t dst)
+{
+ struct mesh_node *node;
+
+ if (IS_UNASSIGNED(dst)) {
+ rl_printf("Destination not set\n");
+ return false;
+ }
+
+ node = node_find_by_addr(dst);
+ if (!node) {
+ rl_printf("Node with unicast address %4.4x unknown\n", dst);
+ return false;
+ }
+
+ if (!node_get_composition(node)) {
+ rl_printf("Node composition for %4.4x unknown\n", dst);
+ return false;
+ }
+
+ return true;
+}
+
static void cmd_bind(const char *args)
{
uint16_t n;
uint8_t msg[32];
int parm_cnt;
- if (IS_UNASSIGNED(target)) {
- rl_printf("Destination not set\n");
+ if (!verify_config_target(target))
return;
- }
parm_cnt = read_input_parameters(args);
if (parm_cnt != 3 && parm_cnt != 4) {
@@ -529,10 +550,8 @@ static void cmd_set_pub(const char *args)
uint8_t msg[32];
int parm_cnt;
- if (IS_UNASSIGNED(target)) {
- rl_printf("Destination not set\n");
+ if (!verify_config_target(target))
return;
- }
n = mesh_opcode_set(OP_CONFIG_MODEL_PUB_SET, msg);
--
2.13.6
next reply other threads:[~2017-11-21 7:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-21 7:08 Inga Stotland [this message]
2017-11-23 10:19 ` [PATCH BlueZ] mesh: validate configuration target Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171121070848.7305-1-inga.stotland@intel.com \
--to=inga.stotland@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).