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

Commit bbeb2b75 authored by Cheney Ni's avatar Cheney Ni Committed by Myles Watson
Browse files

DO NOT MERGE: 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
parent bcb62bd9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1989,6 +1989,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;
        }

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

        if (passkey.length != len) {
            android.util.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));