OSDN Git Service

DO NOT MERGE SMP: Check p_cb->role in smp_br_state_machine_event
authorHansong Zhang <hsz@google.com>
Wed, 30 May 2018 00:38:39 +0000 (17:38 -0700)
committerRyan Longair <rlongair@google.com>
Tue, 12 Jun 2018 18:27:18 +0000 (11:27 -0700)
Bug: 80145946
Test: manual
Change-Id: Ic83eaa4be868d5a345d80cd50a6915c0af719a53
(cherry picked from commit 519b61392a96fbd45bdcc0bfddc881167c20cc23)

stack/smp/smp_br_main.cc

index 260b9c4..55405cc 100644 (file)
@@ -19,6 +19,7 @@
 #include "bt_target.h"
 
 #include <string.h>
+#include "log/log.h"
 #include "smp_int.h"
 
 const char* const smp_br_state_name[SMP_BR_STATE_MAX + 1] = {
@@ -308,6 +309,12 @@ void smp_br_state_machine_event(tSMP_CB* p_cb, tSMP_BR_EVENT event,
     return;
   }
 
+  if (p_cb->role > HCI_ROLE_SLAVE) {
+    SMP_TRACE_ERROR("%s: invalid role %d", __func__, p_cb->role);
+    android_errorWriteLog(0x534e4554, "80145946");
+    return;
+  }
+
   SMP_TRACE_DEBUG("SMP Role: %s State: [%s (%d)], Event: [%s (%d)]",
                   (p_cb->role == HCI_ROLE_SLAVE) ? "Slave" : "Master",
                   smp_get_br_state_name(p_cb->br_state), p_cb->br_state,