]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
A blank hostname is not a valid hostname
authorRoy Marples <roy@marples.name>
Mon, 25 Jan 2016 10:47:32 +0000 (10:47 +0000)
committerRoy Marples <roy@marples.name>
Mon, 25 Jan 2016 10:47:32 +0000 (10:47 +0000)
dhcp-common.c

index ff8a959ea8bbcf6799c39ee0bcf129f23097e1d3..c9aff2e29644e805fc6acee7019a99781cdd4d17 100644 (file)
@@ -64,10 +64,10 @@ dhcp_get_hostname(char *buf, size_t buf_len, const struct if_options *ifo)
                strlcpy(buf, ifo->hostname, buf_len);
 
        /* Deny sending of these local hostnames */
-       if (strcmp(buf, "(none)") == 0 ||
+       if (buf[0] == '\0' || buf[0] == '.' ||
+           strcmp(buf, "(none)") == 0 ||
            strcmp(buf, "localhost") == 0 ||
-           strncmp(buf, "localhost.", strlen("localhost.")) == 0 ||
-           buf[0] == '.')
+           strncmp(buf, "localhost.", strlen("localhost.")) == 0)
                return NULL;
 
        /* Shorten the hostname if required */