Skip to content

Commit

Permalink
Bluetooth: Mesh: Avoid undefined behavior in bit shift in blob_cli.c
Browse files Browse the repository at this point in the history
block_size_log can be 0x20 which will shift 1 by 32 bits which will
cause undefined behavior. Adding ULL to 1 is an option but this will add
little bit more code when debug option is enabled. So simply print the
logarithmic value.

Coverity-ID: 316387
Fixes zephyrproject-rtos#58951

Signed-off-by: Pavel Vasilyev <[email protected]>
  • Loading branch information
PavelVPV authored and nashif committed Jun 8, 2023
1 parent cfd368f commit 242c8f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions subsys/bluetooth/mesh/blob_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,9 +1550,9 @@ int bt_mesh_blob_cli_send(struct bt_mesh_blob_cli *cli,
return -ENODEV;
}

LOG_DBG("\n\tblock size: %u\n\tchunk size: %u\n"
LOG_DBG("\n\tblock size log: %u\n\tchunk size: %u\n"
"\tblob size: %u\n\tmode: %x",
(1 << cli->xfer->block_size_log), cli->xfer->chunk_size,
cli->xfer->block_size_log, cli->xfer->chunk_size,
cli->xfer->size, cli->xfer->mode);

return xfer_start(cli);
Expand Down

0 comments on commit 242c8f1

Please sign in to comment.