Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80a40bb6 authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Reject random addresses that are empty

This case is not described in the command description
but the definition of random addresses does say that
address bits must not be all 0.

Bug: 258434265
Test: m root-canal
Change-Id: I2ba51f6333723beb790759fdf683ebc79585d998
parent 60a1768c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -247,9 +247,17 @@ ErrorCode LinkLayerController::LeSetRandomAddress(Address random_address) {
  // the Controller shall return the error code Command Disallowed (0x0C).
  if (legacy_advertiser_.IsEnabled() || scanner_.IsEnabled() ||
      initiator_.IsEnabled()) {
    LOG_INFO("advertising, scanning or initiating are currently active");
    return ErrorCode::COMMAND_DISALLOWED;
  }

  if (random_address == Address::kEmpty) {
    LOG_INFO("the random address may not be set to 00:00:00:00:00:00");
    return ErrorCode::INVALID_HCI_COMMAND_PARAMETERS;
  }

  LOG_INFO("device random address configured to %s",
           random_address.ToString().c_str());
  random_address_ = random_address;
  return ErrorCode::SUCCESS;
}