Skip to content

Commit

Permalink
[nrf fromtree] bluetooth: mesh: cfg_cli: Update logs when pulling out…
Browse files Browse the repository at this point in the history
… CDP0 and 1

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 <[email protected]>
(cherry picked from commit 1eeee01)
Signed-off-by: Håvard Reierstad <[email protected]>
  • Loading branch information
PavelVPV authored and HaavardRei committed Dec 3, 2024
1 parent 752afb3 commit 44b06d4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion subsys/bluetooth/mesh/cfg_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -2381,13 +2385,15 @@ 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;
}

item->cor_id = net_buf_simple_pull_u8(elem->_buf);
}

if (elem->_buf->len < item_size) {
LOG_DBG("No more elements to pull or missing data");
return NULL;
}

Expand Down

0 comments on commit 44b06d4

Please sign in to comment.