summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-03-27 01:21:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-27 01:21:45 +0000
commit607c5a66ec3bc3075af80f45e39101f2562ae33b (patch)
tree787291dfe887364cfc3836ba26536cb957d093bd /service
parent33da6370769f3d0ba5a6464fe6abdd93d0a8ea8f (diff)
parent6417193a864c3c68da609a143880f6dcfb9f93c1 (diff)
Merge "Fix the issue an invalid ScanResult may cause crash" into rvc-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java16
-rw-r--r--service/java/com/android/server/wifi/util/ScanResultUtil.java20
2 files changed, 33 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 4e07e5ef3..e6a12c16c 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -115,6 +115,7 @@ import com.android.server.wifi.hotspot2.PasspointProvider;
import com.android.server.wifi.util.ApConfigUtil;
import com.android.server.wifi.util.ExternalCallbackTracker;
import com.android.server.wifi.util.RssiUtil;
+import com.android.server.wifi.util.ScanResultUtil;
import com.android.server.wifi.util.WifiHandler;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.wifi.resources.R;
@@ -2194,6 +2195,10 @@ public class WifiServiceImpl extends BaseWifiService {
if (mVerboseLoggingEnabled) {
mLog.info("getMatchingPasspointConfigurations uid=%").c(Binder.getCallingUid()).flush();
}
+ if (!ScanResultUtil.validateScanResultList(scanResults)) {
+ Log.e(TAG, "Attempt to retrieve passpoint with invalid scanResult List");
+ return Collections.emptyMap();
+ }
return mWifiThreadRunner.call(
() -> mPasspointManager.getAllMatchingPasspointProfilesForScanResults(scanResults),
Collections.emptyMap());
@@ -2214,6 +2219,11 @@ public class WifiServiceImpl extends BaseWifiService {
if (mVerboseLoggingEnabled) {
mLog.info("getMatchingOsuProviders uid=%").c(Binder.getCallingUid()).flush();
}
+
+ if (!ScanResultUtil.validateScanResultList(scanResults)) {
+ Log.e(TAG, "Attempt to retrieve OsuProviders with invalid scanResult List");
+ return Collections.emptyMap();
+ }
return mWifiThreadRunner.call(
() -> mPasspointManager.getMatchingOsuProviders(scanResults), Collections.emptyMap());
}
@@ -2290,8 +2300,8 @@ public class WifiServiceImpl extends BaseWifiService {
mLog.info("getWifiConfigsForMatchedNetworkSuggestions uid=%").c(
Binder.getCallingUid()).flush();
}
- if (scanResults == null) {
- Log.e(TAG, "Attempt to retrieve WifiConfiguration with null scanResult List");
+ if (!ScanResultUtil.validateScanResultList(scanResults)) {
+ Log.e(TAG, "Attempt to retrieve WifiConfiguration with invalid scanResult List");
return new ArrayList<>();
}
return mWifiThreadRunner.call(
@@ -2703,7 +2713,7 @@ public class WifiServiceImpl extends BaseWifiService {
return mWifiThreadRunner.call(
() -> {
- if (scanResults == null || scanResults.isEmpty()) {
+ if (!ScanResultUtil.validateScanResultList(scanResults)) {
return mWifiNetworkSuggestionsManager.getMatchingScanResults(
networkSuggestions, mScanRequestProxy.getScanResults());
} else {
diff --git a/service/java/com/android/server/wifi/util/ScanResultUtil.java b/service/java/com/android/server/wifi/util/ScanResultUtil.java
index 320490c0b..dc2281ad2 100644
--- a/service/java/com/android/server/wifi/util/ScanResultUtil.java
+++ b/service/java/com/android/server/wifi/util/ScanResultUtil.java
@@ -243,4 +243,24 @@ public class ScanResultUtil {
}
}
}
+
+ /**
+ * Check if ScarResult list is valid.
+ */
+ public static boolean validateScanResultList(List<ScanResult> scanResults) {
+ if (scanResults == null || scanResults.isEmpty()) {
+ return false;
+ }
+ for (ScanResult scanResult : scanResults) {
+ if (!validate(scanResult)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private static boolean validate(ScanResult scanResult) {
+ return scanResult != null && scanResult.SSID != null
+ && scanResult.capabilities != null && scanResult.BSSID != null;
+ }
}