summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorAlexander Wuerstlein <arw@arw.name>2016-08-29 15:41:10 +0200
committerAlexander Wuerstlein <arw@arw.name>2016-08-31 21:06:32 +0200
commit61da29a98bedac7732cb03c3008d0047de6574f9 (patch)
treed650b3cd0293c452e60c369f073a55a33034127c /services
parent5587ea46dab171fd43716aaaf5344ff87c032582 (diff)
downloadframeworks_base-61da29a98bedac7732cb03c3008d0047de6574f9.zip
frameworks_base-61da29a98bedac7732cb03c3008d0047de6574f9.tar.gz
frameworks_base-61da29a98bedac7732cb03c3008d0047de6574f9.tar.bz2
Ensure DHCP requests have nonempty hostnames
If the net.hostname property is empty or not found, Android issues DHCP requests with an empty hostname field (option 12). RFC2132 section 3.14 prescribes a minimum length of 1 byte for the hostname. To fix this, a generic 'android-dhcp' hostname is used as a fallback. Change-Id: I7a92e7295f72b3255e4fba6498fb4039906eb702
Diffstat (limited to 'services')
-rw-r--r--services/net/java/android/net/dhcp/DhcpPacket.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/services/net/java/android/net/dhcp/DhcpPacket.java b/services/net/java/android/net/dhcp/DhcpPacket.java
index 8927bfa..f97df83 100644
--- a/services/net/java/android/net/dhcp/DhcpPacket.java
+++ b/services/net/java/android/net/dhcp/DhcpPacket.java
@@ -602,7 +602,12 @@ abstract class DhcpPacket {
protected void addCommonClientTlvs(ByteBuffer buf) {
addTlv(buf, DHCP_MAX_MESSAGE_SIZE, (short) MAX_LENGTH);
addTlv(buf, DHCP_VENDOR_CLASS_ID, "android-dhcp-" + Build.VERSION.RELEASE);
- addTlv(buf, DHCP_HOST_NAME, SystemProperties.get("net.hostname"));
+
+ /* the default 'android-dhcp' is there to make sure the hostname is
+ * never empty, because the DHCP standard forbids it (RFC2132, section
+ * 3.14) and certain DHCP forwarders and servers ignore such malformed
+ * requests */
+ addTlv(buf, DHCP_HOST_NAME, SystemProperties.get("net.hostname", "android-dhcp"));
}
/**