sd-path: FOREACH_LINE exorcism
authorLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 14:15:18 +0000 (16:15 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 14:23:45 +0000 (16:23 +0200)
src/libsystemd/sd-path/sd-path.c

index ec6e597..d590c90 100644 (file)
@@ -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))