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

Commit c4b0ade2 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Defuse Bundles parsed by the system process." into nyc-dev

parents 5c4eeb98 d136e51a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -710,6 +710,10 @@ public class ActivityOptions {

    /** @hide */
    public ActivityOptions(Bundle opts) {
        // If the remote side sent us bad parcelables, they won't get the
        // results they want, which is their loss.
        opts.setDefusable(true);

        mPackageName = opts.getString(KEY_PACKAGE_NAME);
        try {
            mUsageTimeReport = opts.getParcelable(KEY_USAGE_TIME_REPORT);
+6 −1
Original line number Diff line number Diff line
@@ -1332,9 +1332,14 @@ class ContextImpl extends Context {
            }
        }
        try {
            return ActivityManagerNative.getDefault().registerReceiver(
            final Intent intent = ActivityManagerNative.getDefault().registerReceiver(
                    mMainThread.getApplicationThread(), mBasePackageName,
                    rd, filter, broadcastPermission, userId);
            if (intent != null) {
                intent.setExtrasClassLoader(getClassLoader());
                intent.prepareToEnterProcess();
            }
            return intent;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+3 −0
Original line number Diff line number Diff line
@@ -913,6 +913,8 @@ public final class LoadedApk {
                mDispatcher = new WeakReference<LoadedApk.ReceiverDispatcher>(rd);
                mStrongRef = strong ? rd : null;
            }

            @Override
            public void performReceive(Intent intent, int resultCode, String data,
                    Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
                LoadedApk.ReceiverDispatcher rd = mDispatcher.get();
@@ -996,6 +998,7 @@ public final class LoadedApk {
                try {
                    ClassLoader cl =  mReceiver.getClass().getClassLoader();
                    intent.setExtrasClassLoader(cl);
                    intent.prepareToEnterProcess();
                    setExtrasClassLoader(cl);
                    receiver.setPendingResult(this);
                    receiver.onReceive(mContext, intent);
+11 −0
Original line number Diff line number Diff line
@@ -836,6 +836,17 @@ public class ClipData implements Parcelable {
        }
    }

    /** {@hide} */
    public void prepareToEnterProcess() {
        final int size = mItems.size();
        for (int i = 0; i < size; i++) {
            final Item item = mItems.get(i);
            if (item.mIntent != null) {
                item.mIntent.prepareToEnterProcess();
            }
        }
    }

    /** @hide */
    public void fixUris(int contentUserHint) {
        final int size = mItems.size();
+19 −1
Original line number Diff line number Diff line
@@ -6037,13 +6037,20 @@ public class Intent implements Parcelable, Cloneable {
        return mExtras != null && mExtras.hasFileDescriptors();
    }

    /** @hide */
    /** {@hide} */
    public void setAllowFds(boolean allowFds) {
        if (mExtras != null) {
            mExtras.setAllowFds(allowFds);
        }
    }

    /** {@hide} */
    public void setDefusable(boolean defusable) {
        if (mExtras != null) {
            mExtras.setDefusable(defusable);
        }
    }

    /**
     * Retrieve extended data from the intent.
     *
@@ -8938,6 +8945,17 @@ public class Intent implements Parcelable, Cloneable {
     * @hide
     */
    public void prepareToEnterProcess() {
        // We just entered destination process, so we should be able to read all
        // parcelables inside.
        setDefusable(true);

        if (mSelector != null) {
            mSelector.prepareToEnterProcess();
        }
        if (mClipData != null) {
            mClipData.prepareToEnterProcess();
        }

        if (mContentUserHint != UserHandle.USER_CURRENT) {
            if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
                fixUris(mContentUserHint);
Loading