2019-07-26 04:34:02

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: [PATCH BlueZ v5 4/5] mesh: Check that element indexes are consecutive

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

diff --git a/mesh/node.c b/mesh/node.c
index 86676bf20..f937fe361 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.22.0