From: Lennart Poettering Date: Thu, 18 Oct 2018 14:15:18 +0000 (+0200) Subject: sd-path: FOREACH_LINE exorcism X-Git-Tag: v240~513^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=710bf2aeb2821df42a6e3f51aa7fa55ab07378f3;p=thirdparty%2Fsystemd.git sd-path: FOREACH_LINE exorcism --- diff --git a/src/libsystemd/sd-path/sd-path.c b/src/libsystemd/sd-path/sd-path.c index ec6e597ec01..d590c90f2e6 100644 --- a/src/libsystemd/sd-path/sd-path.c +++ b/src/libsystemd/sd-path/sd-path.c @@ -4,6 +4,7 @@ #include "alloc-util.h" #include "architecture.h" +#include "def.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" @@ -75,7 +76,6 @@ static int from_user_dir(const char *field, char **buffer, const char **ret) { _cleanup_free_ char *b = NULL; _cleanup_free_ const char *fn = NULL; const char *c = NULL; - char line[LINE_MAX]; size_t n; int r; @@ -103,9 +103,16 @@ static int from_user_dir(const char *field, char **buffer, const char **ret) { * xdg-user-dirs does upstream */ n = strlen(field); - FOREACH_LINE(line, f, return -errno) { + for (;;) { + _cleanup_free_ char *line = NULL; char *l, *p, *e; + r = read_line(f, LONG_LINE_MAX, &line); + if (r < 0) + return r; + if (r == 0) + break; + l = strstrip(line); if (!strneq(l, field, n))