diff options
author | Roshan Pius <rpius@google.com> | 2019-04-25 09:15:51 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-04-26 08:38:31 -0700 |
commit | 08135433b40efd21abab4e929d365b2cc0de1e86 (patch) | |
tree | 7aec0f5d987a1f13bbcf7dca83f6cca459b65f2c /tests | |
parent | d04a29f8721e70ac1ae4e1aa82d18baa53bd8f97 (diff) |
NativeUtil: Perform range checks on ssid bytes size
NativeUtil.encodeSsid/decodeSsid should perform range checks because the
output/input is coming from binder/hwbinder interfaces which assume
the ssid is not malformed (i.e within spec mandated size range).
Most of the callers of these methods already handle
IllegalArgumentException (including the hidden network list built in
WifiCondControl). This should fix the reported issue of a hidden SSID
added with size > 32 causing crash in wificond.
Bug: 130843221
Test: Device boots up & connects to wifi networks.
Test: Regression tests.
Test: atest com.android.server.wifi
Change-Id: I12d8f3b548a65005932bd8bc1c74de37769b0ee8
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/NativeUtilTest.java | 31 |
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 |