linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michał Lowas-Rzechonek" <michal.lowas-rzechonek@silvair.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 4/5] mesh: Check that element indexes are consecutive
Date: Tue, 23 Jul 2019 12:06:22 +0200	[thread overview]
Message-ID: <20190723100623.6957-5-michal.lowas-rzechonek@silvair.com> (raw)
In-Reply-To: <20190723100623.6957-1-michal.lowas-rzechonek@silvair.com>

This patch checks that application does not omit element indexes.

---
 mesh/node.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mesh/node.c b/mesh/node.c
index bfb0dc5b4..8ff75c110 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -898,6 +898,7 @@ uint8_t node_friend_mode_get(struct mesh_node *node)
 uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz)
 {
 	uint16_t n, features;
+	uint16_t num_ele = 0;
 	const struct l_queue_entry *ele_entry;
 
 	if (!node || !node->comp || sz < MIN_COMP_SIZE)
@@ -935,6 +936,11 @@ uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz)
 		uint8_t num_s = 0, num_v = 0;
 		uint8_t *mod_buf;
 
+		if (ele->idx != num_ele)
+			return 0;
+
+		num_ele++;
+
 		/* At least fit location and zeros for number of models */
 		if ((n + 4) > sz)
 			return n;
@@ -997,6 +1003,9 @@ element_done:
 
 	}
 
+	if (!num_ele)
+		return 0;
+
 	return n;
 }
 
-- 
2.19.1


  parent reply	other threads:[~2019-07-23 10:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23 10:06 [PATCH BlueZ v2 0/5] Use composition data to validate app against the node Michał Lowas-Rzechonek
2019-07-23 10:06 ` [PATCH BlueZ v2 1/5] mesh: Convert void pointers to anonymous unions in managed_obj_request Michał Lowas-Rzechonek
2019-07-23 10:06 ` [PATCH BlueZ v2 2/5] mesh: Validate application by comparing composition data Michał Lowas-Rzechonek
2019-07-24  4:30   ` Stotland, Inga
2019-07-24  7:55     ` michal.lowas-rzechonek
2019-07-24 18:09       ` Stotland, Inga
2019-07-24 19:12         ` michal.lowas-rzechonek
2019-07-24 21:24           ` Stotland, Inga
2019-07-23 10:06 ` [PATCH BlueZ v2 3/5] mesh: Keep element and model lists sorted and unique Michał Lowas-Rzechonek
2019-07-23 10:06 ` Michał Lowas-Rzechonek [this message]
2019-07-23 10:06 ` [PATCH BlueZ v2 5/5] mesh: Check that config server is present in primary element Michał Lowas-Rzechonek
2019-07-24  4:38 ` [PATCH BlueZ v2 0/5] Use composition data to validate app against the node Stotland, Inga

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=20190723100623.6957-5-michal.lowas-rzechonek@silvair.com \
    --to=michal.lowas-rzechonek@silvair.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).