Skip to content

Commit 617154f

Browse files
PavelVPVnashif
authored andcommitted
Bluetooth: Mesh: Avoid undefined behavior when block_size_log is 0x20
Use ULL suffix to promote the type of the shift operand to uint64_t to avoid undefined behavior when block_size_log is 32. Coverity-CID: 316387, GitHub issue #58528 Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent 395f250 commit 617154f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

subsys/bluetooth/mesh/blob_cli.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,8 +1531,12 @@ int bt_mesh_blob_cli_send(struct bt_mesh_blob_cli *cli,
15311531
cli->xfer = xfer;
15321532
cli->inputs = inputs;
15331533
cli->io = io;
1534-
cli->block_count = DIV_ROUND_UP(cli->xfer->size,
1535-
(1U << cli->xfer->block_size_log));
1534+
1535+
if (cli->xfer->block_size_log == 0x20) {
1536+
cli->block_count = 1;
1537+
} else {
1538+
cli->block_count = DIV_ROUND_UP(cli->xfer->size, (1U << cli->xfer->block_size_log));
1539+
}
15361540

15371541
block_set(cli, 0);
15381542

0 commit comments

Comments
 (0)