From 44b06d41d72a21834a81e71b1ddd91c5dcc96c41 Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Tue, 3 Dec 2024 15:14:22 +0100 Subject: [PATCH] [nrf fromtree] bluetooth: mesh: cfg_cli: Update logs when pulling out CDP0 and 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commits puts in order log messages when unpacking CDP0 and CDP1 so that it a bit more clear where the error happens. Signed-off-by: Pavel Vasilyev (cherry picked from commit 1eeee010bd00be90acfc0693cfdf04970d45e006) Signed-off-by: HÃ¥vard Reierstad --- subsys/bluetooth/mesh/cfg_cli.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/mesh/cfg_cli.c b/subsys/bluetooth/mesh/cfg_cli.c index 225b60e84a8..9c4301e0b09 100644 --- a/subsys/bluetooth/mesh/cfg_cli.c +++ b/subsys/bluetooth/mesh/cfg_cli.c @@ -2275,6 +2275,7 @@ struct bt_mesh_comp_p0_elem *bt_mesh_comp_p0_elem_pull(const struct bt_mesh_comp size_t modlist_size; if (page->_buf->len < 4) { + LOG_DBG("Buffer is too short"); return NULL; } @@ -2285,6 +2286,7 @@ struct bt_mesh_comp_p0_elem *bt_mesh_comp_p0_elem_pull(const struct bt_mesh_comp modlist_size = elem->nsig * 2 + elem->nvnd * 4; if (page->_buf->len < modlist_size) { + LOG_DBG("Buffer is shorter than number of claimed models"); return NULL; } @@ -2321,7 +2323,7 @@ struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull(struct net_buf_simple *bu struct bt_mesh_comp_p1_elem *elem) { if (buf->len < 4) { - LOG_DBG("No more elements to pull or missing data"); + LOG_DBG("Buffer is too short"); return NULL; } size_t elem_size = 0; @@ -2333,6 +2335,7 @@ struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull(struct net_buf_simple *bu elem->nvnd = net_buf_simple_pull_u8(buf); for (i = 0; i < elem->nsig + elem->nvnd; i++) { if (buf->len < elem_size + 1) { + LOG_DBG("Buffer is shorter than number of claimed models"); return NULL; } @@ -2351,6 +2354,7 @@ struct bt_mesh_comp_p1_elem *bt_mesh_comp_p1_elem_pull(struct net_buf_simple *bu } if (buf->len < elem_size) { + LOG_DBG("No more elements to pull or missing data"); return NULL; } @@ -2381,6 +2385,7 @@ struct bt_mesh_comp_p1_model_item *bt_mesh_comp_p1_item_pull( item_size = item->ext_item_cnt * (item->format + 1); if (item->cor_present) { if (elem->_buf->len < 1) { + LOG_DBG("Coresponding_Present field is claimed but not present"); return NULL; } @@ -2388,6 +2393,7 @@ struct bt_mesh_comp_p1_model_item *bt_mesh_comp_p1_item_pull( } if (elem->_buf->len < item_size) { + LOG_DBG("No more elements to pull or missing data"); return NULL; }