diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2014-04-07 20:00:33 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-04-07 20:00:33 +0000 |
commit | 128e937108035b77537f279dc0bc85a116906819 (patch) | |
tree | a1e06628f26ef9892e6f14f6511ec5ab6c600733 /wifi | |
parent | efbe7cc0ff5c85cc7956bb3099402c7ebbe20591 (diff) | |
parent | 106627e07cecfa8a9bcc43578fde78652fc59eba (diff) | |
download | frameworks_base-128e937108035b77537f279dc0bc85a116906819.zip frameworks_base-128e937108035b77537f279dc0bc85a116906819.tar.gz frameworks_base-128e937108035b77537f279dc0bc85a116906819.tar.bz2 |
am 106627e0: am e42ce676: am ebf23a8d: am 74acf23a: am 3c417fbf: Merge "DO NOT MERGE Sanitize WifiConfigs" into jb-mr1-dev
* commit '106627e07cecfa8a9bcc43578fde78652fc59eba':
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 bf82792..4b3a72f 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -16,12 +16,17 @@ 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 android.text.TextUtils; +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 @@ -580,6 +585,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 2d9cc29..3502954 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) { |