summaryrefslogtreecommitdiff
path: root/src/timesync/timesyncd-conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/timesync/timesyncd-conf.c')
-rw-r--r--src/timesync/timesyncd-conf.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c
index 124d03da0b..a26c2dad7f 100644
--- a/src/timesync/timesyncd-conf.c
+++ b/src/timesync/timesyncd-conf.c
@@ -1,25 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
-/***
- This file is part of systemd.
-
- Copyright 2014 Kay Sievers, Lennart Poettering
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
#include "alloc-util.h"
#include "def.h"
+#include "dns-domain.h"
#include "extract-word.h"
#include "string-util.h"
#include "timesyncd-conf.h"
@@ -49,6 +32,14 @@ int manager_parse_server_string(Manager *m, ServerType type, const char *string)
if (r == 0)
break;
+ r = dns_name_is_valid_or_address(word);
+ if (r < 0)
+ return log_error_errno(r, "Failed to check validity of NTP server name or address '%s': %m", word);
+ if (r == 0) {
+ log_error("Invalid NTP server name or address, ignoring: %s", word);
+ continue;
+ }
+
/* Filter out duplicates */
LIST_FOREACH(names, n, first)
if (streq_ptr(n->string, word)) {