]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: fix assertion triggered when r == 0
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 Jan 2022 20:24:31 +0000 (05:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 Jan 2022 06:52:14 +0000 (15:52 +0900)
Fixes #22178.

src/resolve/resolved-etc-hosts.c

index 9af3a27bb10b0961e2422ad818f90e76544e1cf1..a8da6c3d8810c36efbe45f8ca435d44278044bda 100644 (file)
@@ -109,7 +109,10 @@ static int parse_line(EtcHosts *hosts, unsigned nr, const char *line) {
 
                 r = dns_name_is_valid_ldh(name);
                 if (r <= 0) {
-                        log_warning_errno(r, "/etc/hosts:%u: hostname \"%s\" is not valid, ignoring.", nr, name);
+                        if (r < 0)
+                                log_warning_errno(r, "/etc/hosts:%u: Failed to check the validity of hostname \"%s\", ignoring: %m", nr, name);
+                        else
+                                log_warning("/etc/hosts:%u: hostname \"%s\" is not valid, ignoring.", nr, name);
                         continue;
                 }