summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorThomas Wendt <thoemy@gmx.net>2013-04-12 00:51:36 +0200
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-04-13 06:11:06 -0700
commita954774db18b02f6bcb837da615d74483b7416bb (patch)
tree84a99f2519daa5e62753dc9adc47e52eac66c95c /wifi
parentd8dc80a820f78b7e01fc1252f76e771a96ed5364 (diff)
downloadframeworks_base-a954774db18b02f6bcb837da615d74483b7416bb.zip
frameworks_base-a954774db18b02f6bcb837da615d74483b7416bb.tar.gz
frameworks_base-a954774db18b02f6bcb837da615d74483b7416bb.tar.bz2
wifi: Fix StringIndexOutOfBoundsException for incorrectly encoded SSIDs
If the last character of a SSID is a unescaped backslash then WifiSsid convertToBytes() will throw a StringIndexOutOfBoundsException and takes the whole ROM down. The issue was reported by andreip in the HTC One X XDA thread. His SSID was set to "/ Andrew \". 04-10 21:33:54.265 E/AndroidRuntime(10479): *** FATAL EXCEPTION IN SYSTEM PROCESS: WifiStateMachine 04-10 21:33:54.265 E/AndroidRuntime(10479): java.lang.StringIndexOutOfBoundsException: length=10; index=10 04-10 21:33:54.265 E/AndroidRuntime(10479): at android.net.wifi.WifiSsid.convertToBytes(WifiSsid.java:89) 04-10 21:33:54.265 E/AndroidRuntime(10479): at android.net.wifi.WifiSsid.createFromAsciiEncoded(WifiSsid.java:54) 04-10 21:33:54.265 E/AndroidRuntime(10479): at android.net.wifi.WifiStateMachine.setScanResults(WifiStateMachine.java:1522) 04-10 21:33:54.265 E/AndroidRuntime(10479): at android.net.wifi.WifiStateMachine.access$7100(WifiStateMachine.java:103) 04-10 21:33:54.265 E/AndroidRuntime(10479): at android.net.wifi.WifiStateMachine$SupplicantStartedState.processMessage(WifiStateMachine.java:2511) 04-10 21:33:54.265 E/AndroidRuntime(10479): at com.android.internal.util.StateMachine$SmHandler.processMsg(StateMachine.java:905) 04-10 21:33:54.265 E/AndroidRuntime(10479): at com.android.internal.util.StateMachine$SmHandler.handleMessage(StateMachine.java:760) 04-10 21:33:54.265 E/AndroidRuntime(10479): at android.os.Handler.dispatchMessage(Handler.java:99) 04-10 21:33:54.265 E/AndroidRuntime(10479): at android.os.Looper.loop(Looper.java:137) 04-10 21:33:54.265 E/AndroidRuntime(10479): at android.os.HandlerThread.run(HandlerThread.java:60) Change-Id: I8273decacfffea4e4cae3bb957c925833dab09e2
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiSsid.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/wifi/java/android/net/wifi/WifiSsid.java b/wifi/java/android/net/wifi/WifiSsid.java
index 55e9b2d..c04fa1b 100644
--- a/wifi/java/android/net/wifi/WifiSsid.java
+++ b/wifi/java/android/net/wifi/WifiSsid.java
@@ -86,6 +86,11 @@ public class WifiSsid implements Parcelable {
switch (c) {
case '\\':
i++;
+ if (i >= asciiEncoded.length()) {
+ octets.write('\\');
+ break;
+ }
+
switch(asciiEncoded.charAt(i)) {
case '\\':
octets.write('\\');