summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2015-09-10 18:12:18 +0900
committerLorenzo Colitti <lorenzo@google.com>2015-10-11 16:06:11 +0900
commit4e4d59eeef86fa8560d35c00168869b0a066f962 (patch)
tree588b2f4fa478083bfb05d689b8effd89e7c8dd9a /core
parenteb0bbd45f62fcaff26151b54a7b3ea16bb67e3be (diff)
downloadframeworks_base-4e4d59eeef86fa8560d35c00168869b0a066f962.zip
frameworks_base-4e4d59eeef86fa8560d35c00168869b0a066f962.tar.gz
frameworks_base-4e4d59eeef86fa8560d35c00168869b0a066f962.tar.bz2
Connect the DHCP UDP socket to the server.
This makes it so that the socket cannot receive datagrams from anybody except the DHCP server. This does not improve security, because we never read from the UDP socket anyway, but it does make ListeningPortsTest pass. Bug: 23906864 Bug: 23933386 Change-Id: Ib090273a417f7eb2ac1ee3309260249b72fb8345
Diffstat (limited to 'core')
-rw-r--r--core/java/android/net/DhcpResults.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/core/java/android/net/DhcpResults.java b/core/java/android/net/DhcpResults.java
index 87c063f..97bd5d2 100644
--- a/core/java/android/net/DhcpResults.java
+++ b/core/java/android/net/DhcpResults.java
@@ -21,7 +21,6 @@ import android.os.Parcel;
import android.text.TextUtils;
import android.util.Log;
-import java.net.InetAddress;
import java.net.Inet4Address;
import java.util.Objects;
@@ -34,7 +33,7 @@ import java.util.Objects;
public class DhcpResults extends StaticIpConfiguration {
private static final String TAG = "DhcpResults";
- public InetAddress serverAddress;
+ public Inet4Address serverAddress;
/** Vendor specific information (from RFC 2132). */
public String vendorInfo;
@@ -142,7 +141,7 @@ public class DhcpResults extends StaticIpConfiguration {
private static void readFromParcel(DhcpResults dhcpResults, Parcel in) {
StaticIpConfiguration.readFromParcel(dhcpResults, in);
dhcpResults.leaseDuration = in.readInt();
- dhcpResults.serverAddress = NetworkUtils.unparcelInetAddress(in);
+ dhcpResults.serverAddress = (Inet4Address) NetworkUtils.unparcelInetAddress(in);
dhcpResults.vendorInfo = in.readString();
}
@@ -183,8 +182,8 @@ public class DhcpResults extends StaticIpConfiguration {
public boolean setServerAddress(String addrString) {
try {
- serverAddress = NetworkUtils.numericToInetAddress(addrString);
- } catch (IllegalArgumentException e) {
+ serverAddress = (Inet4Address) NetworkUtils.numericToInetAddress(addrString);
+ } catch (IllegalArgumentException|ClassCastException e) {
Log.e(TAG, "setServerAddress failed with addrString " + addrString);
return true;
}