From b751c3e747a90915964b332b1bf64a471a6a9659 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 10 Feb 2020 00:40:13 +0900 Subject: [PATCH] network fix parser for IPv6Token= extract_first_word() drops multiple ':'. So, it is not suitable for parsing 'static' case. --- src/network/networkd-ndisc.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 4bdc26a38fc..12f8c1a1dcc 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -962,7 +962,6 @@ int config_parse_address_generation_type( void *userdata) { _cleanup_free_ IPv6Token *token = NULL; - _cleanup_free_ char *word = NULL; union in_addr_union buffer; Network *network = data; const char *p; @@ -978,35 +977,19 @@ int config_parse_address_generation_type( return 0; } - p = rvalue; - r = extract_first_word(&p, &word, ":", 0); - if (r == -ENOMEM) - return log_oom(); - if (r <= 0) { - log_syntax(unit, LOG_ERR, filename, line, r, - "Invalid IPv6Token= , ignoring assignment: %s", rvalue); - return 0; - } - r = ipv6token_new(&token); if (r < 0) return log_oom(); - if (streq(word, "static")) + if ((p = startswith(rvalue, "static:"))) token->address_generation_type = IPV6_TOKEN_ADDRESS_GENERATION_STATIC; - else if (streq(word, "prefixstable")) + else if ((p = startswith(rvalue, "prefixstable:"))) token->address_generation_type = IPV6_TOKEN_ADDRESS_GENERATION_PREFIXSTABLE; else { token->address_generation_type = IPV6_TOKEN_ADDRESS_GENERATION_STATIC; p = rvalue; } - if (isempty(p)) { - log_syntax(unit, LOG_ERR, filename, line, 0, - "Invalid IPv6Token= , ignoring assignment: %s", rvalue); - return 0; - } - r = in_addr_from_string(AF_INET6, p, &buffer); if (r < 0) { log_syntax(unit, LOG_ERR, filename, line, r, -- 2.47.3