diff options
author | Tom Gundersen <teg@jklm.no> | 2015-10-27 11:41:06 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-10-27 11:41:06 +0100 |
commit | f47fc3ffc4b69a00083a76308f777b52afb8efbf (patch) | |
tree | 0b7680493cbba742c306e3061ae8c3955a9e0a7d /src/resolve/resolved-conf.c | |
parent | c2b4c0e68a374519e4817da9e1ae150af5b23ce4 (diff) | |
parent | 880603a13c7ff8a6cab87135dd1eac3f0cd9baab (diff) |
Merge pull request #1693 from ssahani/word
timesysnd: port to extract_first_word
Diffstat (limited to 'src/resolve/resolved-conf.c')
-rw-r--r-- | src/resolve/resolved-conf.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c index aca0d891c6..22a5c7fdbf 100644 --- a/src/resolve/resolved-conf.c +++ b/src/resolve/resolved-conf.c @@ -22,10 +22,9 @@ #include "conf-parser.h" #include "string-util.h" #include "resolved-conf.h" +#include "extract-word.h" int manager_parse_dns_server(Manager *m, DnsServerType type, const char *string) { - const char *word, *state; - size_t length; DnsServer *first; int r; @@ -34,19 +33,23 @@ int manager_parse_dns_server(Manager *m, DnsServerType type, const char *string) first = type == DNS_SERVER_FALLBACK ? m->fallback_dns_servers : m->dns_servers; - FOREACH_WORD_QUOTED(word, length, string, state) { - char buffer[length+1]; - int family; + for(;;) { + _cleanup_free_ char *word; union in_addr_union addr; bool found = false; DnsServer *s; + int family; + + r = extract_first_word(&string, &word, NULL, 0); + if (r < 0) + return log_error_errno(r, "Failed to parse resolved dns server syntax \"%s\": %m", string); - memcpy(buffer, word, length); - buffer[length] = 0; + if (r == 0) + break; - r = in_addr_from_string_auto(buffer, &family, &addr); + r = in_addr_from_string_auto(word, &family, &addr); if (r < 0) { - log_warning("Ignoring invalid DNS address '%s'", buffer); + log_warning("Ignoring invalid DNS address '%s'", word); continue; } |