Skip to content

Commit 4571485

Browse files
sjancjhedberg
authored andcommitted
Bluetooth: Mesh: Fix invalid write in private beacon server
There is no guarantess enum will be packed so passing uint8_t as node_id to bt_mesh_subnet_priv_node_id_get() could (and likely will) result in writing past stack variable. Signed-off-by: Szymon Janc <[email protected]>
1 parent 393f542 commit 4571485

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

subsys/bluetooth/mesh/priv_beacon_srv.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,14 @@ static int handle_node_id_get(const struct bt_mesh_model *mod,
151151
struct bt_mesh_msg_ctx *ctx,
152152
struct net_buf_simple *buf)
153153
{
154-
uint8_t node_id, status;
154+
enum bt_mesh_feat_state node_id;
155155
uint16_t net_idx;
156+
uint8_t status;
156157

157158
net_idx = net_buf_simple_pull_le16(buf) & 0xfff;
158159

159-
status = bt_mesh_subnet_priv_node_id_get(net_idx, (enum bt_mesh_feat_state *)&node_id);
160-
node_id_status_rsp(mod, ctx, status, net_idx, node_id);
160+
status = bt_mesh_subnet_priv_node_id_get(net_idx, &node_id);
161+
node_id_status_rsp(mod, ctx, status, net_idx, (uint8_t)node_id);
161162

162163
return 0;
163164
}

0 commit comments

Comments
 (0)