Skip to content

Commit

Permalink
bluetooth: fix possible memset start out of bound
Browse files Browse the repository at this point in the history
  • Loading branch information
bramoosterhuis committed Feb 28, 2024
1 parent 2782bed commit 2818136
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/bluetooth/drivers/BCM43XX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ namespace Bluetooth {
uint32_t MACAddress(const uint8_t length, const uint8_t address[])
{
uint8_t data[6];
::memset(data, 0, sizeof(data));
::memcpy(data, address, std::min(length, static_cast<uint8_t>(sizeof(data))));
::memset(&(data[length]), 0, sizeof(data) - std::min(length, static_cast<uint8_t>(sizeof(data))));
const uint16_t command = cmd_opcode_pack(OGF_VENDOR_CMD, BCM43XX_WRITE_LOCAL_ADDRESS);

Exchange::Response response(Exchange::COMMAND_PKT, command);
uint32_t result = Exchange(Exchange::Request(Exchange::COMMAND_PKT, command, sizeof(data), address), response, 500);
uint32_t result = Exchange(Exchange::Request(Exchange::COMMAND_PKT, command, sizeof(data), data), response, 500);

if ((result == Core::ERROR_NONE) && (response[3] != CMD_SUCCESS)) {
TRACE_L1("Failed to set the MAC address\n");
Expand Down

0 comments on commit 2818136

Please sign in to comment.