network-generator: allow empty hostname

Fixes #14319.
This commit is contained in:
Yu Watanabe 2019-12-12 19:01:21 +09:00
parent 288a4787a5
commit 21a925a4ac

View 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) { static int parse_cmdline_ip_address(Context *context, int family, const char *value) {
union in_addr_union addr = {}, peer = {}, gateway = {}; 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; unsigned char prefixlen;
int r; int r;
@ -599,9 +599,11 @@ static int parse_cmdline_ip_address(Context *context, int family, const char *va
if (!p) if (!p)
return -EINVAL; return -EINVAL;
if (p != value) {
hostname = strndupa(value, p - value); hostname = strndupa(value, p - value);
if (!hostname_is_valid(hostname, false)) if (!hostname_is_valid(hostname, false))
return -EINVAL; return -EINVAL;
}
value = p + 1; value = p + 1;