Skip to content

Commit 067872d

Browse files
PavelVPVm-alperen-sener
authored andcommitted
[nrf fromtree] bluetooth: mesh: pb_adv: ensure that bitwise NOT doesn't result in 0
Ensure that ~(link.rx.seg) & SEG_NVAL doesn't result in 0. Fixes #84804 Coverity-CID: 393090 Signed-off-by: Pavel Vasilyev <[email protected]> (cherry picked from commit fcf09dd)
1 parent 7644e96 commit 067872d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

subsys/bluetooth/mesh/pb_adv.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,14 @@ static void gen_prov_start(struct prov_rx *rx, struct net_buf_simple *buf)
637637

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

640+
/* This (BIT(0) is set) can happen if we received a Transaction Continuation PDU, before
641+
* receiving a Transaction Start PDU (see `gen_prov_cont`). Now we received the Transaction
642+
* Start PDU and we can extract the last segment number. Knowing this, we check if
643+
* previously received segment exceeds the last segment number. If so, we reject the
644+
* Transaction Start PDU.
645+
*/
640646
if ((link.rx.seg & BIT(0)) &&
647+
((link.rx.seg & SEG_NVAL) != SEG_NVAL) &&
641648
(find_msb_set((~link.rx.seg) & SEG_NVAL) - 1 > link.rx.last_seg)) {
642649
LOG_ERR("Invalid segment index %u", seg);
643650
prov_failed(PROV_ERR_NVAL_FMT);

0 commit comments

Comments
 (0)