From: Yu Watanabe Date: Wed, 19 Jan 2022 20:24:31 +0000 (+0900) Subject: resolve: fix assertion triggered when r == 0 X-Git-Tag: v251-rc1~495 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98b1eb711cfc70776fefd3d4ec437a6a4f9aeff2;p=thirdparty%2Fsystemd.git resolve: fix assertion triggered when r == 0 Fixes #22178. --- diff --git a/src/resolve/resolved-etc-hosts.c b/src/resolve/resolved-etc-hosts.c index 9af3a27bb10..a8da6c3d881 100644 --- a/src/resolve/resolved-etc-hosts.c +++ b/src/resolve/resolved-etc-hosts.c @@ -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; }