diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2014-04-07 19:36:44 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-04-07 19:36:44 +0000 |
commit | 74acf23a1eef75628c8fa9e2ff7ba08ed4258558 (patch) | |
tree | 8c631c4242b8785673c3c7ff9e6012275642b51a /wifi | |
parent | 7bd0b65233d0ef34114ecb93d734dfe4351f470d (diff) | |
parent | 3c417fbf21133340cbbe3539d87c453f81ae3a9d (diff) | |
download | frameworks_base-74acf23a1eef75628c8fa9e2ff7ba08ed4258558.zip frameworks_base-74acf23a1eef75628c8fa9e2ff7ba08ed4258558.tar.gz frameworks_base-74acf23a1eef75628c8fa9e2ff7ba08ed4258558.tar.bz2 |
am 3c417fbf: Merge "DO NOT MERGE Sanitize WifiConfigs" into jb-mr1-dev
* commit '3c417fbf21133340cbbe3539d87c453f81ae3a9d':
DO NOT MERGE Sanitize WifiConfigs
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfiguration.java | 43 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 3 |
2 files changed, 46 insertions, 0 deletions
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index c4fe1b4..4b5aa9c 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -16,11 +16,16 @@ package android.net.wifi; +import android.net.LinkAddress; import android.net.LinkProperties; +import android.net.RouteInfo; import android.os.Parcelable; import android.os.Parcel; +import java.util.ArrayList; import java.util.BitSet; +import java.util.Collection; +import java.util.Iterator; /** * A class representing a configured Wi-Fi network, including the @@ -615,6 +620,44 @@ public class WifiConfiguration implements Parcelable { } } + /** + * We don't want to use routes other than the first default and + * correct direct-connect route, or addresses beyond the first as + * the user can't see them in the UI and malicious apps + * can do malicious things with them. In particular specific routes + * circumvent VPNs of this era. + * + * @hide + */ + public static LinkProperties stripUndisplayableConfig(LinkProperties lp) { + if (lp == null) return lp; + + LinkProperties newLp = new LinkProperties(lp); + Iterator<LinkAddress> i = lp.getLinkAddresses().iterator(); + RouteInfo directConnectRoute = null; + if (i.hasNext()) { + LinkAddress addr = i.next(); + Collection<LinkAddress> newAddresses = new ArrayList<LinkAddress>(1); + newAddresses.add(addr); + newLp.setLinkAddresses(newAddresses); + directConnectRoute = new RouteInfo(addr,null); + } + boolean defaultAdded = false; + Collection<RouteInfo> routes = lp.getRoutes(); + Collection<RouteInfo> newRoutes = new ArrayList<RouteInfo>(2); + for (RouteInfo route : routes) { + if (defaultAdded == false && route.isDefaultRoute()) { + newRoutes.add(route); + defaultAdded = true; + } + if (route.equals(directConnectRoute)) { + newRoutes.add(route); + } + } + newLp.setRoutes(newRoutes); + return newLp; + } + /** Implement the Parcelable interface {@hide} */ public void writeToParcel(Parcel dest, int flags) { dest.writeInt(networkId); diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index dafa8e8..e316b30 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -1606,9 +1606,11 @@ public class WifiStateMachine extends StateMachine { private void configureLinkProperties() { if (mWifiConfigStore.isUsingStaticIp(mLastNetworkId)) { mLinkProperties = mWifiConfigStore.getLinkProperties(mLastNetworkId); + mLinkProperties = WifiConfiguration.stripUndisplayableConfig(mLinkProperties); } else { synchronized (mDhcpInfoInternal) { mLinkProperties = mDhcpInfoInternal.makeLinkProperties(); + mLinkProperties = WifiConfiguration.stripUndisplayableConfig(mLinkProperties); } mLinkProperties.setHttpProxy(mWifiConfigStore.getProxyProperties(mLastNetworkId)); } @@ -1816,6 +1818,7 @@ public class WifiStateMachine extends StateMachine { //DHCP renewal in connected state LinkProperties linkProperties = dhcpInfoInternal.makeLinkProperties(); linkProperties.setHttpProxy(mWifiConfigStore.getProxyProperties(mLastNetworkId)); + linkProperties = WifiConfiguration.stripUndisplayableConfig(linkProperties); linkProperties.setInterfaceName(mInterfaceName); if (!linkProperties.equals(mLinkProperties)) { if (DBG) { |