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

Commit 08fc72d0 authored by Robin Lee's avatar Robin Lee
Browse files

Check DeviceOwner exists before using packageName

Creating a profile owner when there is no device owner present also
creates a new DeviceOwner object without packageName set -- this
situation can lead to a null pointer access when calling isDeviceOwner.

Change-Id: I31eab498d78cadc67a1aedd205b458dee2d27705
parent c4f6c351
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1315,9 +1315,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            }
            if (admin.getUid() != Binder.getCallingUid()) {
                // If trying to remove device owner, refuse when the caller is not the owner.
                if (mDeviceOwner != null
                        && adminReceiver.getPackageName().equals(
                        mDeviceOwner.getDeviceOwnerPackageName())) {
                if (isDeviceOwner(adminReceiver.getPackageName())) {
                    return;
                }
                mContext.enforceCallingOrSelfPermission(
@@ -2793,6 +2791,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
        synchronized (this) {
            return mDeviceOwner != null
                    && mDeviceOwner.hasDeviceOwner()
                    && mDeviceOwner.getDeviceOwnerPackageName().equals(packageName);
        }
    }