summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorDavid Su <dysu@google.com>2020-08-03 15:14:55 -0700
committerDavid Su <dysu@google.com>2020-08-05 17:21:17 +0000
commit3a3fcdb97c6b0fc39391bce8365ff6807374df4c (patch)
treeb7001351d01b1e73fa7a286042e7926ed870ca8f /service
parentb64129c61416da5a3817d328a7adb166485254ea (diff)
WifiScoreCard: catch IllegalArgumentException when SSID > 32 bytes
Bug: 162705230 Test: atest FrameworksWifiTests Change-Id: I1ef139ff38f5dcb72514a0719cca0be5d6bd4d7e
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiScoreCard.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/WifiScoreCard.java b/service/java/com/android/server/wifi/WifiScoreCard.java
index 64da835f0..2ab5fb466 100644
--- a/service/java/com/android/server/wifi/WifiScoreCard.java
+++ b/service/java/com/android/server/wifi/WifiScoreCard.java
@@ -1689,11 +1689,18 @@ public class WifiScoreCard {
* @return
*/
public static long computeHashLong(String ssid, MacAddress mac, String l2KeySeed) {
+ final ArrayList<Byte> decodedSsid;
+ try {
+ decodedSsid = NativeUtil.decodeSsid(ssid);
+ } catch (IllegalArgumentException e) {
+ Log.e(TAG, "NativeUtil.decodeSsid failed: malformed string: " + ssid);
+ return 0;
+ }
byte[][] parts = {
// Our seed keeps the L2Keys specific to this device
l2KeySeed.getBytes(),
// ssid is either quoted utf8 or hex-encoded bytes; turn it into plain bytes.
- NativeUtil.byteArrayFromArrayList(NativeUtil.decodeSsid(ssid)),
+ NativeUtil.byteArrayFromArrayList(decodedSsid),
// And the BSSID
mac.toByteArray()
};