summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-18 16:16:06 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-18 16:23:45 +0200
commit0a6488b441251e14ea23bf9564da5bc9fce7c6c6 (patch)
tree0276283ac3728c86ac74ce90913206bbe1f4d094
parent271c8ec50f48fae5523f8355b5233fa1db5c6a42 (diff)
downloadsystemd-0a6488b441251e14ea23bf9564da5bc9fce7c6c6.tar.gz
resolved-dns-trust-anchor: FOREACH_LINE excorcism
Also, properly ignore these read errors, and say so.
-rw-r--r--src/resolve/resolved-dns-trust-anchor.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/resolve/resolved-dns-trust-anchor.c b/src/resolve/resolved-dns-trust-anchor.c
index dc6b746189..c5ec93b724 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);