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

Commit 0a46096d authored by Archie Pusaka's avatar Archie Pusaka
Browse files

btif_sock: prevent crash from logging NULL UUIDs

It is valid to pass a NULL UUID into btsock_connect. Therefore, this
condition must be checked before converting it to string for logging.

Bug: 328763360
Bug: 328764473
Test: m -j
Test: Pass CTSV CoC tests
Flag: EXEMPT, logging changes
Change-Id: I70a7549983593c38aa1d90c892f4adcd6ce24494
parent 7ada9e56
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -213,9 +213,10 @@ static bt_status_t btsock_connect(const RawAddress* bd_addr, btsock_type_t type,
  *sock_fd = INVALID_FD;
  bt_status_t status = BT_STATUS_FAIL;

  btif_sock_connection_logger(
      *bd_addr, 0, type, SOCKET_CONNECTION_STATE_CONNECTING,
      SOCKET_ROLE_CONNECTION, app_uid, channel, 0, 0, uuid->ToString().c_str());
  btif_sock_connection_logger(*bd_addr, 0, type,
                              SOCKET_CONNECTION_STATE_CONNECTING,
                              SOCKET_ROLE_CONNECTION, app_uid, channel, 0, 0,
                              uuid ? uuid->ToString().c_str() : "");
  switch (type) {
    case BTSOCK_RFCOMM:
      status =
@@ -246,7 +247,7 @@ static bt_status_t btsock_connect(const RawAddress* bd_addr, btsock_type_t type,
    btif_sock_connection_logger(*bd_addr, 0, type,
                                SOCKET_CONNECTION_STATE_DISCONNECTED,
                                SOCKET_ROLE_CONNECTION, app_uid, channel, 0, 0,
                                uuid->ToString().c_str());
                                uuid ? uuid->ToString().c_str() : "");
  }
  return status;
}