From 3a3fcdb97c6b0fc39391bce8365ff6807374df4c Mon Sep 17 00:00:00 2001 From: David Su Date: Mon, 3 Aug 2020 15:14:55 -0700 Subject: WifiScoreCard: catch IllegalArgumentException when SSID > 32 bytes Bug: 162705230 Test: atest FrameworksWifiTests Change-Id: I1ef139ff38f5dcb72514a0719cca0be5d6bd4d7e --- service/java/com/android/server/wifi/WifiScoreCard.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'service') 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 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() }; -- cgit v1.2.3