Skip to content

Commit a63c515

Browse files
PavelVPVjhedberg
authored andcommitted
Bluetooth: Mesh: Check SegN when receiving Transaction Start PDU
When receiving Transaction Start PDU, assure that number of segments needed to send a Provisioning PDU with TotalLength size is equal to SegN value provided in the Transaction Start PDU. Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent c33ce95 commit a63c515

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

subsys/bluetooth/mesh/pb_adv.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static struct bt_mesh_send_cb buf_sent_cb = {
149149
.end = buf_sent,
150150
};
151151

152-
static uint8_t last_seg(uint8_t len)
152+
static uint8_t last_seg(uint16_t len)
153153
{
154154
if (len <= START_PAYLOAD_MAX) {
155155
return 0;
@@ -482,6 +482,13 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf)
482482
return;
483483
}
484484

485+
if (START_LAST_SEG(rx->gpc) != last_seg(link.rx.buf->len)) {
486+
BT_ERR("Invalid SegN (%u, calculated %u)", START_LAST_SEG(rx->gpc),
487+
last_seg(link.rx.buf->len));
488+
prov_failed(PROV_ERR_NVAL_FMT);
489+
return;
490+
}
491+
485492
prov_clear_tx();
486493

487494
link.rx.last_seg = START_LAST_SEG(rx->gpc);

0 commit comments

Comments
 (0)