Use read_line() and LONG_LINE_MAX to read values configuration files.

This commit is contained in:
Tiago Salem Herrmann 2017-12-12 13:43:17 -02:00
parent 4a0e9289bf
commit a668bfe88a

View file

@ -106,16 +106,16 @@ static int parse_file(OrderedHashmap *sysctl_options, const char *path, bool ign
log_debug("Parsing %s", path); log_debug("Parsing %s", path);
for (;;) { 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; void *v;
int k; int k;
k = read_line(f, LONG_LINE_MAX, &l);
if (k == 0)
break;
if (!fgets(l, sizeof(l), f)) { if (k < 0)
if (feof(f)) return log_error_errno(k, "Failed to read file '%s', ignoring: %m", path);
break;
return log_error_errno(errno, "Failed to read file '%s', ignoring: %m", path);
}
c++; c++;