]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved-dns-trust-anchor: FOREACH_LINE excorcism
authorLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 14:16:06 +0000 (16:16 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 14:23:45 +0000 (16:23 +0200)
Also, properly ignore these read errors, and say so.

src/resolve/resolved-dns-trust-anchor.c

index dc6b74618937c15aa52658dde93b9d24fb5b915c..c5ec93b724485dc61bcb36ec81284c21250d355b 100644 (file)
@@ -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);