summaryrefslogtreecommitdiffstats
path: root/src/timesync/timesyncd-manager.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-06-03 11:54:29 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-06-13 06:51:17 +0200
commitdcb37458cba57e94b8cd37167f25ad5430b83fd5 (patch)
treef1e9352600b114e411bc14a0c32981a42d4d2d2f /src/timesync/timesyncd-manager.c
parentconf-parser: simplify conf_parse_path() (diff)
downloadsystemd-dcb37458cba57e94b8cd37167f25ad5430b83fd5.tar.xz
systemd-dcb37458cba57e94b8cd37167f25ad5430b83fd5.zip
timesync: check validity of NTP server name or address
Diffstat (limited to 'src/timesync/timesyncd-manager.c')
-rw-r--r--src/timesync/timesyncd-manager.c10
1 files changed, 10 insertions, 0 deletions
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;