From: Lennart Poettering Date: Thu, 18 Oct 2018 14:16:06 +0000 (+0200) Subject: resolved-dns-trust-anchor: FOREACH_LINE excorcism X-Git-Tag: v240~513^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a6488b441251e14ea23bf9564da5bc9fce7c6c6;p=thirdparty%2Fsystemd.git resolved-dns-trust-anchor: FOREACH_LINE excorcism Also, properly ignore these read errors, and say so. --- diff --git a/src/resolve/resolved-dns-trust-anchor.c b/src/resolve/resolved-dns-trust-anchor.c index dc6b7461893..c5ec93b7244 100644 --- a/src/resolve/resolved-dns-trust-anchor.c +++ b/src/resolve/resolved-dns-trust-anchor.c @@ -433,7 +433,6 @@ static int dns_trust_anchor_load_files( STRV_FOREACH(f, files) { _cleanup_fclose_ FILE *g = NULL; - char line[LINE_MAX]; unsigned n = 0; g = fopen(*f, "r"); @@ -441,13 +440,22 @@ static int dns_trust_anchor_load_files( if (errno == ENOENT) continue; - log_warning_errno(errno, "Failed to open %s: %m", *f); + log_warning_errno(errno, "Failed to open '%s', ignoring: %m", *f); continue; } - FOREACH_LINE(line, g, log_warning_errno(errno, "Failed to read %s, ignoring: %m", *f)) { + for (;;) { + _cleanup_free_ char *line = NULL; char *l; + r = read_line(g, LONG_LINE_MAX, &line); + if (r < 0) { + log_warning_errno(r, "Failed to read '%s', ignoring: %m", *f); + break; + } + if (r == 0) + break; + n++; l = strstrip(line);