cgtop: fgets() excorcism
authorLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 11:34:12 +0000 (13:34 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 18 Oct 2018 11:34:12 +0000 (13:34 +0200)
src/cgtop/cgtop.c

index 1976d99..e4123e5 100644 (file)
@@ -343,10 +343,14 @@ static int process(
                 }
 
                 for (;;) {
-                        char line[LINE_MAX], *l;
+                        _cleanup_free_ char *line = NULL;
                         uint64_t k, *q;
+                        char *l;
 
-                        if (!fgets(line, sizeof(line), f))
+                        r = read_line(f, LONG_LINE_MAX, &line);
+                        if (r < 0)
+                                return r;
+                        if (r == 0)
                                 break;
 
                         /* Trim and skip the device */