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

Commit da3422f1 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
Change-Id: Ie2dd01e0b192e7ed1fe4b464618ddfa415dbf15c
Merged-In: Ie2dd01e0b192e7ed1fe4b464618ddfa415dbf15c
parent 950c8a19
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1986,6 +1986,11 @@ public class AdapterService extends Service {
            return false;
        }

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

        byte[] addr = Utils.getBytesFromAddress(device.getAddress());
        return pinReplyNative(addr, accept, len, pinCode);
    }
@@ -1997,6 +2002,11 @@ public class AdapterService extends Service {
            return false;
        }

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

        byte[] addr = Utils.getBytesFromAddress(device.getAddress());
        return sspReplyNative(addr, AbstractionLayer.BT_SSP_VARIANT_PASSKEY_ENTRY, accept,
                Utils.byteArrayToInt(passkey));