Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d88569d1 authored by Alexander Wuerstlein's avatar Alexander Wuerstlein Committed by Gerrit Code Review
Browse files

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
parent 79440ed0
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -617,7 +617,11 @@ abstract class DhcpPacket {

    private String getHostname() {
        if (testOverrideHostname != null) return testOverrideHostname;
        return 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 */
        return SystemProperties.get("net.hostname", "android-dhcp");
    }

    /**