Fix an exception caused by incorrect data handling
The prefixes in WifiEnterpriseConfig are optional, and should be treated
as such. If the prefix doesn't exist, it is possible for an
exception to be thrown (if the value size is smaller than prefix size).
Bug: 10304089
Change-Id: Id9b2bc0e371c818e35a5aa1913ee1697f167e19e
diff --git a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
index 4bee937..e357804a 100644
--- a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
+++ b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
@@ -721,7 +721,13 @@
String value = mFields.get(key);
// Uninitialized or known to be empty after reading from supplicant
if (TextUtils.isEmpty(value) || EMPTY_VALUE.equals(value)) return "";
- return removeDoubleQuotes(value).substring(prefix.length());
+
+ value = removeDoubleQuotes(value);
+ if (value.startsWith(prefix)) {
+ return value.substring(prefix.length());
+ } else {
+ return value;
+ }
}
/** Set a value with an optional prefix at key