summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-04-26 20:05:49 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-04-26 20:05:49 +0000
commitd18a74adc11d63d1d8363dc6ad4edd1a1880c43b (patch)
tree958108b24ef48b82633857e5119d2230def498a2 /tests
parentf6adbd1c7d24bc4edcf299900151a436daf2398e (diff)
parent08135433b40efd21abab4e929d365b2cc0de1e86 (diff)
Merge "NativeUtil: Perform range checks on ssid bytes size" into qt-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java
index 79dcccfcc..d4bcb479e 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java
@@ -128,6 +128,18 @@ public class NativeUtilTest {
}
/**
+ * Test that conversion of SSID string with len > 32 to bytes fail.
+ */
+ @Test
+ public void testLargeSsidDecodeFails() throws Exception {
+ try {
+ NativeUtil.decodeSsid("\"asdrewqdfgyuiopldsqwertyuiolhdergcv\"");
+ fail("Expected ssid decode to fail");
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ /**
* Test that conversion of ssid bytes to hex string ssid works.
*/
@Test
@@ -178,6 +190,25 @@ public class NativeUtilTest {
}
/**
+ * Test that conversion of SSID bytes with len > 32 to string fail.
+ */
+ @Test
+ public void testLargeSsidEncodeFails() throws Exception {
+ try {
+ NativeUtil.encodeSsid(new ArrayList<>(
+ Arrays.asList((byte) 0xf5, (byte) 0xe4, (byte) 0xab, (byte) 0x78, (byte) 0x78,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a,
+ (byte) 0xab, (byte) 0x34, (byte) 0x32, (byte) 0x43, (byte) 0x9a)));
+ fail("Expected ssid encode to fail");
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
+ /**
* Test that parsing of quoted SSID to byte array and vice versa works.
*/
@Test