diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2014-04-07 19:54:13 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-04-07 19:54:13 +0000 |
commit | 106627e07cecfa8a9bcc43578fde78652fc59eba (patch) | |
tree | 454d6f726253e81d41414a57e2bbd8f3c6a01106 /wifi | |
parent | d1c82f8fc22216e9b544e3a3b521bcad05bc113d (diff) | |
parent | e42ce676f54742f2d47c26adaa90407c2cb8cec8 (diff) | |
download | frameworks_base-106627e07cecfa8a9bcc43578fde78652fc59eba.zip frameworks_base-106627e07cecfa8a9bcc43578fde78652fc59eba.tar.gz frameworks_base-106627e07cecfa8a9bcc43578fde78652fc59eba.tar.bz2 |
am e42ce676: am ebf23a8d: am 74acf23a: am 3c417fbf: Merge "DO NOT MERGE Sanitize WifiConfigs" into jb-mr1-dev
* commit 'e42ce676f54742f2d47c26adaa90407c2cb8cec8':
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) { |