summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2020-06-17 17:43:53 -0700
committerxshu <xshu@google.com>2020-06-17 19:26:40 -0700
commitef4f7dc4ea5619b713bcfaa4985338ec07b9f479 (patch)
tree33f3613a17df314f4f323e2bd8d21e3c8824a12e /service
parent41c8058406f2de77c0105cd4a82c4ad1dd00fcfa (diff)
Fix NPE in BssidBlocklistMonitor
Due to unexpected orderings of events happening in ClientModeImpl, sometimes invalid inputs are being passed to BssidBlocklistMonitor to cause a NPE. This patch fixes the crash but does not address the root cause. Bug: 159183809 Test: atest com.android.server.wifi Change-Id: I6991b29949f9799662b8d29a4e0621fed9ff8cf2
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/BssidBlocklistMonitor.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
index 96770443d..dffd77443 100644
--- a/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
+++ b/service/java/com/android/server/wifi/BssidBlocklistMonitor.java
@@ -220,6 +220,12 @@ public class BssidBlocklistMonitor {
*/
public void blockBssidForDurationMs(@NonNull String bssid, @NonNull String ssid,
long durationMs) {
+ if (bssid == null || ssid == null || WifiManager.UNKNOWN_SSID.equals(ssid)
+ || bssid.equals(ClientModeImpl.SUPPLICANT_BSSID_ANY) || durationMs <= 0) {
+ Log.e(TAG, "Invalid input: BSSID=" + bssid + ", SSID=" + ssid
+ + ", durationMs=" + durationMs);
+ return;
+ }
BssidStatus status = getOrCreateBssidStatus(bssid, ssid);
if (status.isInBlocklist
&& status.blocklistEndTimeMs - mClock.getWallClockMillis() > durationMs) {
@@ -407,6 +413,9 @@ public class BssidBlocklistMonitor {
int prevSize = mBssidStatusMap.size();
mBssidStatusMap.entrySet().removeIf(e -> {
BssidStatus status = e.getValue();
+ if (status.ssid == null) {
+ return false;
+ }
if (status.ssid.equals(ssid)) {
mBssidStatusHistoryLogger.add(status, "clearBssidBlocklistForSsid");
return true;