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

Commit d6c84aa3 authored by Cheney Ni's avatar Cheney Ni
Browse files

AdapterService: Check the PIN code length before using

The length is assigned by the framework. We should be better to check
again before using, and dropped any unexcepted input.

Bug: 139287605
Test: PoC, atest -t BluetoothInstrumentationTests:com.android.bluetooth.btservice
Change-Id: Ie2dd01e0b192e7ed1fe4b464618ddfa415dbf15c
parent 283bf918
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -2233,6 +2233,12 @@ public class AdapterService extends Service {
            return false;
        }

        if (pinCode.length != len) {
            android.util.EventLog.writeEvent(0x534e4554, "139287605", -1,
                    "PIN code length mismatch");
            return false;
        }

        StatsLog.write(StatsLog.BLUETOOTH_BOND_STATE_CHANGED,
                obfuscateAddress(device), 0, device.getType(),
                BluetoothDevice.BOND_BONDING,
@@ -2249,6 +2255,12 @@ public class AdapterService extends Service {
            return false;
        }

        if (passkey.length != len) {
            android.util.EventLog.writeEvent(0x534e4554, "139287605", -1,
                    "Passkey length mismatch");
            return false;
        }

        StatsLog.write(StatsLog.BLUETOOTH_BOND_STATE_CHANGED,
                obfuscateAddress(device), 0, device.getType(),
                BluetoothDevice.BOND_BONDING,