Bluetooth: Mesh: Fix DST field check when send

Add check for dst field in transport layer tx function.

Fixes: #29868

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
This commit is contained in:
Lingao Meng 2020-11-08 12:23:00 +08:00 committed by Carles Cufí
commit 7e302979f3

View file

@ -638,6 +638,13 @@ int bt_mesh_trans_send(struct bt_mesh_net_tx *tx, struct net_buf_simple *msg,
tx->ctx->send_rel = true;
}
if (tx->ctx->addr == BT_MESH_ADDR_UNASSIGNED ||
(!BT_MESH_ADDR_IS_UNICAST(tx->ctx->addr) &&
BT_MESH_IS_DEV_KEY(tx->ctx->app_idx))) {
BT_ERR("Invalid destination address");
return -EINVAL;
}
BT_DBG("net_idx 0x%04x app_idx 0x%04x dst 0x%04x", tx->sub->net_idx,
tx->ctx->app_idx, tx->ctx->addr);
BT_DBG("len %u: %s", msg->len, bt_hex(msg->data, msg->len));
@ -1005,6 +1012,12 @@ int bt_mesh_ctl_send(struct bt_mesh_net_tx *tx, uint8_t ctl_op, void *data,
tx->ctx->app_idx = BT_MESH_KEY_UNUSED;
if (tx->ctx->addr == BT_MESH_ADDR_UNASSIGNED ||
BT_MESH_ADDR_IS_VIRTUAL(tx->ctx->addr)) {
BT_ERR("Invalid destination address");
return -EINVAL;
}
BT_DBG("src 0x%04x dst 0x%04x ttl 0x%02x ctl 0x%02x", tx->src,
tx->ctx->addr, tx->ctx->send_ttl, ctl_op);
BT_DBG("len %zu: %s", data_len, bt_hex(data, data_len));