]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Use read_line() and LONG_LINE_MAX to read values configuration files.
authorTiago Salem Herrmann <therrmann@suse.com>
Tue, 12 Dec 2017 15:43:17 +0000 (13:43 -0200)
committerTiago Salem Herrmann <therrmann@suse.com>
Wed, 13 Dec 2017 17:03:33 +0000 (15:03 -0200)
src/sysctl/sysctl.c

index 4c468d011ad75e73c15340e49c859e7ad26528f5..a1dc95b2bb2dec021ea98a7772fb6274a1987058 100644 (file)
@@ -106,16 +106,16 @@ static int parse_file(OrderedHashmap *sysctl_options, const char *path, bool ign
 
         log_debug("Parsing %s", path);
         for (;;) {
-                char l[LINE_MAX], *p, *value, *new_value, *property, *existing;
+                char *p, *value, *new_value, *property, *existing;
+                _cleanup_free_ char *l = NULL;
                 void *v;
                 int k;
+                k = read_line(f, LONG_LINE_MAX, &l);
+                if (k == 0)
+                        break;
 
-                if (!fgets(l, sizeof(l), f)) {
-                        if (feof(f))
-                                break;
-
-                        return log_error_errno(errno, "Failed to read file '%s', ignoring: %m", path);
-                }
+                if (k < 0)
+                        return log_error_errno(k, "Failed to read file '%s', ignoring: %m", path);
 
                 c++;