From dcb37458cba57e94b8cd37167f25ad5430b83fd5 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 3 Jun 2018 18:54:29 +0900 Subject: timesync: check validity of NTP server name or address --- src/timesync/timesyncd-manager.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/timesync/timesyncd-manager.c') diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 46036c41f7..2c565aa8f8 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -20,6 +20,7 @@ #include "sd-daemon.h" #include "alloc-util.h" +#include "dns-domain.h" #include "fd-util.h" #include "fs-util.h" #include "list.h" @@ -968,6 +969,15 @@ static int manager_network_read_link_servers(Manager *m) { STRV_FOREACH(i, ntp) { bool found = false; + r = dns_name_is_valid_or_address(*i); + if (r < 0) { + log_error_errno(r, "Failed to check validity of NTP server name or address '%s': %m", *i); + goto clear; + } else if (r == 0) { + log_error("Invalid NTP server name or address, ignoring: %s", *i); + continue; + } + LIST_FOREACH(names, n, m->link_servers) if (streq(n->string, *i)) { n->marked = false; -- cgit v1.2.3