diff options
| author | Chiachang Wang <chiachangwang@google.com> | 2021-08-20 10:42:52 +0800 |
|---|---|---|
| committer | Chiachang Wang <chiachangwang@google.com> | 2021-08-20 03:40:29 +0000 |
| commit | c57eb8c6ad462a514f200a94093f94e902959f70 (patch) | |
| tree | 556919f275bd1dc48e47ec842796ff993265cd1b | |
| parent | 089b5546c32336228feb2cf8326d1e3e9a6efa86 (diff) | |
Add null check for the taken callback
The requestTetheredInterface() and releaseTetheredInterface() in
EthernetManager is annotated as @NonNull. Basically, the taken
callback parameter to the service implementation should also be
@NonNull. However, it still possible to use native commands to
call the method in the aidl. If a null callback is taken, it may
cause unexpected results and cause crashes. Add a null check and
throw NPE as a warning.
Bug: 190058445
Test: adb commands
Change-Id: I18fd63aba3f7326597fc3a8c93ba8c9097bf7348
| -rw-r--r-- | service-t/src/com/android/server/ethernet/EthernetServiceImpl.java | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java b/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java index 3fc6aab758..6b0ce32644 100644 --- a/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java +++ b/service-t/src/com/android/server/ethernet/EthernetServiceImpl.java @@ -35,6 +35,7 @@ import com.android.internal.util.IndentingPrintWriter; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -172,6 +173,7 @@ public class EthernetServiceImpl extends IEthernetManager.Stub { @Override public void requestTetheredInterface(ITetheredInterfaceCallback callback) { + Objects.requireNonNull(callback, "callback must not be null"); NetworkStack.checkNetworkStackPermissionOr(mContext, android.Manifest.permission.NETWORK_SETTINGS); mTracker.requestTetheredInterface(callback); @@ -179,6 +181,7 @@ public class EthernetServiceImpl extends IEthernetManager.Stub { @Override public void releaseTetheredInterface(ITetheredInterfaceCallback callback) { + Objects.requireNonNull(callback, "callback must not be null"); NetworkStack.checkNetworkStackPermissionOr(mContext, android.Manifest.permission.NETWORK_SETTINGS); mTracker.releaseTetheredInterface(callback); |
