diff options
author | Roshan Pius <rpius@google.com> | 2019-04-26 18:00:16 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-04-26 18:00:16 -0700 |
commit | 74ce29ced626e96ee95a301312bd0c6ff93aaa28 (patch) | |
tree | 775038a15e4cc95d3f4afa7d3294446ee1bda995 /service | |
parent | ab19acd9145088b31e22160b8846130965611dfd (diff) | |
parent | f96d27e876c284f13df9198a4355e427970badb9 (diff) |
Merge "NativeUtil: Perform range checks on ssid bytes size" into qt-dev am: d18a74adc1
am: f96d27e876
Change-Id: Idb836495dd6f8ee9b50eea1a5f36c44bc8710b92
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiVendorHal.java | 3 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/util/NativeUtil.java | 10 |
2 files changed, 9 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index 4b6a3495e..8023bff49 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -2233,9 +2233,6 @@ public class WifiVendorHal { for (String ssidStr : config.whitelistSsids) { byte[] ssid = NativeUtil.byteArrayFromArrayList( NativeUtil.decodeSsid(ssidStr)); - if (ssid.length > 32) { - throw new IllegalArgumentException("configureRoaming: ssid too long"); - } roamingConfig.ssidWhitelist.add(ssid); } } diff --git a/service/java/com/android/server/wifi/util/NativeUtil.java b/service/java/com/android/server/wifi/util/NativeUtil.java index 2329d2e32..d904399a3 100644 --- a/service/java/com/android/server/wifi/util/NativeUtil.java +++ b/service/java/com/android/server/wifi/util/NativeUtil.java @@ -42,6 +42,7 @@ public class NativeUtil { private static final int MAC_LENGTH = 6; private static final int MAC_OUI_LENGTH = 3; private static final int MAC_STR_LENGTH = MAC_LENGTH * 2 + 5; + private static final int SSID_BYTES_MAX_LEN = 32; /** * Convert the string to byte array list. @@ -272,7 +273,11 @@ public class NativeUtil { * @throws IllegalArgumentException for null string. */ public static ArrayList<Byte> decodeSsid(String ssidStr) { - return hexOrQuotedStringToBytes(ssidStr); + ArrayList<Byte> ssidBytes = hexOrQuotedStringToBytes(ssidStr); + if (ssidBytes.size() > SSID_BYTES_MAX_LEN) { + throw new IllegalArgumentException("ssid bytes size out of range: " + ssidBytes.size()); + } + return ssidBytes; } /** @@ -286,6 +291,9 @@ public class NativeUtil { * @throws IllegalArgumentException for null bytes. */ public static String encodeSsid(ArrayList<Byte> ssidBytes) { + if (ssidBytes.size() > SSID_BYTES_MAX_LEN) { + throw new IllegalArgumentException("ssid bytes size out of range: " + ssidBytes.size()); + } return bytesToHexOrQuotedString(ssidBytes); } |