]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network-generator: allow empty hostname
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Dec 2019 10:01:21 +0000 (19:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 12 Dec 2019 10:01:24 +0000 (19:01 +0900)
Fixes #14319.

src/network/generator/network-generator.c

index 81afa9530762421bf0cc160ee909e689635e8fdc..bed1e42697c434d075028c5a6e665f8665df9aad 100644 (file)
@@ -574,7 +574,7 @@ static int parse_netmask_or_prefixlen(int family, const char **value, unsigned c
 
 static int parse_cmdline_ip_address(Context *context, int family, const char *value) {
         union in_addr_union addr = {}, peer = {}, gateway = {};
-        const char *hostname, *ifname, *dhcp_type, *dns, *p;
+        const char *hostname = NULL, *ifname, *dhcp_type, *dns, *p;
         unsigned char prefixlen;
         int r;
 
@@ -599,9 +599,11 @@ static int parse_cmdline_ip_address(Context *context, int family, const char *va
         if (!p)
                 return -EINVAL;
 
-        hostname = strndupa(value, p - value);
-        if (!hostname_is_valid(hostname, false))
-                return -EINVAL;
+        if (p != value) {
+                hostname = strndupa(value, p - value);
+                if (!hostname_is_valid(hostname, false))
+                        return -EINVAL;
+        }
 
         value = p + 1;