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

Commit 62099956 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by The Android Automerger
Browse files

Work on issue #17656716: Unhandled exception in Window Manager

Create descriptive errors when sending unreasonably large
parcels through IPC.

Change-Id: Ie93b5372a8ed87541db282876c4eeeae69a1e8bd
parent 3ead24e3
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.os;

import android.util.Log;
import android.util.Slog;
import com.android.internal.util.FastPrintWriter;

import java.io.FileDescriptor;
@@ -48,7 +49,7 @@ public class Binder implements IBinder {
     * of classes can potentially create leaks.
     */
    private static final boolean FIND_POTENTIAL_LEAKS = false;
    private static final String TAG = "Binder";
    static final String TAG = "Binder";

    /**
     * Control whether dump() calls are allowed.
@@ -386,6 +387,13 @@ public class Binder implements IBinder {
        }
    }

    static void checkParcel(Parcel parcel, String msg) {
        if (parcel.dataSize() >= 800*1024) {
            // Trying to send > 800k, this is way too much
            Slog.wtfStack(TAG, msg + parcel.dataSize());
        }
    }

    private native final void init();
    private native final void destroy();

@@ -424,6 +432,7 @@ public class Binder implements IBinder {
            reply.writeException(re);
            res = true;
        }
        checkParcel(reply, "Unreasonably large binder reply buffer: ");
        reply.recycle();
        data.recycle();
        return res;
@@ -438,8 +447,13 @@ final class BinderProxy implements IBinder {
        return null;
    }

    public boolean transact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
        Binder.checkParcel(data, "Unreasonably large binder buffer: ");
        return transactNative(code, data, reply, flags);
    }

    public native String getInterfaceDescriptor() throws RemoteException;
    public native boolean transact(int code, Parcel data, Parcel reply,
    public native boolean transactNative(int code, Parcel data, Parcel reply,
            int flags) throws RemoteException;
    public native void linkToDeath(DeathRecipient recipient, int flags)
            throws RemoteException;
+1 −1
Original line number Diff line number Diff line
@@ -1239,7 +1239,7 @@ static const JNINativeMethod gBinderProxyMethods[] = {
    {"pingBinder",          "()Z", (void*)android_os_BinderProxy_pingBinder},
    {"isBinderAlive",       "()Z", (void*)android_os_BinderProxy_isBinderAlive},
    {"getInterfaceDescriptor", "()Ljava/lang/String;", (void*)android_os_BinderProxy_getInterfaceDescriptor},
    {"transact",            "(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z", (void*)android_os_BinderProxy_transact},
    {"transactNative",      "(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z", (void*)android_os_BinderProxy_transact},
    {"linkToDeath",         "(Landroid/os/IBinder$DeathRecipient;I)V", (void*)android_os_BinderProxy_linkToDeath},
    {"unlinkToDeath",       "(Landroid/os/IBinder$DeathRecipient;I)Z", (void*)android_os_BinderProxy_unlinkToDeath},
    {"destroy",             "()V", (void*)android_os_BinderProxy_destroy},