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

Commit 8b0caf0d authored by Chienyuan's avatar Chienyuan
Browse files

Check ch_id in UIPC_Read before using it

Bug: 113495295
Test: manual
Change-Id: I4930e476b55f2745cb967cbb44edd80a9ff85b34
parent 4033c5e8
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -621,15 +621,15 @@ bool UIPC_Send(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id,
uint32_t UIPC_Read(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id,
                   UNUSED_ATTR uint16_t* p_msg_evt, uint8_t* p_buf,
                   uint32_t len) {
  int n_read = 0;
  int fd = uipc.ch[ch_id].fd;
  struct pollfd pfd;

  if (ch_id >= UIPC_CH_NUM) {
    BTIF_TRACE_ERROR("UIPC_Read : invalid ch id %d", ch_id);
    return 0;
  }

  int n_read = 0;
  int fd = uipc.ch[ch_id].fd;
  struct pollfd pfd;

  if (fd == UIPC_DISCONNECTED) {
    BTIF_TRACE_ERROR("UIPC_Read : channel %d closed", ch_id);
    return 0;