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

Commit 941ed306 authored by Chia-chi Yeh's avatar Chia-chi Yeh Committed by Android (Google) Code Review
Browse files

Merge "VPN: avoid leaking file descriptors."

parents ec08cacd 3f3337a6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@
    <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    <protected-broadcast android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" />

    <protected-broadcast android:name="android.net.vpn.action.REVOKED" />

    <protected-broadcast android:name="android.nfc.action.LLCP_LINK_STATE_CHANGED" />
    <protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_ON_DETECTED" />
    <protected-broadcast android:name="com.android.nfc_extras.action.RF_FIELD_OFF_DETECTED" />
+11 −3
Original line number Diff line number Diff line
@@ -102,14 +102,22 @@ public class Vpn extends INetworkManagementEventObserver.Stub {

    /**
     * Protect a socket from routing changes by binding it to the given
     * interface. The socket is NOT closed by this method.
     * interface. The socket IS closed by this method.
     *
     * @param socket The socket to be bound.
     * @param name The name of the interface.
     */
    public void protect(ParcelFileDescriptor socket, String name) {
        try {
            mContext.enforceCallingPermission(VPN, "protect");
            nativeProtect(socket.getFd(), name);
        } finally {
            try {
                socket.close();
            } catch (Exception e) {
                // ignore
            }
        }
    }

    /**