From e1b9fc23eb0fb2f67cd9e4a1209db0da2eaa0c9f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 18 Oct 2018 16:17:23 +0200 Subject: [PATCH] resolved-resolv-conf: FOREACH_LINE excorcism --- src/resolve/resolved-resolv-conf.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c index 1e19586..6b74daf 100644 --- a/src/resolve/resolved-resolv-conf.c +++ b/src/resolve/resolved-resolv-conf.c @@ -4,6 +4,7 @@ #include #include "alloc-util.h" +#include "def.h" #include "dns-domain.h" #include "fd-util.h" #include "fileio-label.h" @@ -89,7 +90,6 @@ static bool file_is_our_own(const struct stat *st) { int manager_read_resolv_conf(Manager *m) { _cleanup_fclose_ FILE *f = NULL; struct stat st; - char line[LINE_MAX]; unsigned n = 0; int r; @@ -137,10 +137,19 @@ int manager_read_resolv_conf(Manager *m) { dns_server_mark_all(m->dns_servers); dns_search_domain_mark_all(m->search_domains); - FOREACH_LINE(line, f, r = -errno; goto clear) { + for (;;) { + _cleanup_free_ char *line = NULL; const char *a; char *l; + r = read_line(f, LONG_LINE_MAX, &line); + if (r < 0) { + log_error_errno(r, "Failed to read /etc/resolv.conf: %m"); + goto clear; + } + if (r == 0) + break; + n++; l = strstrip(line); -- 2.7.4