summaryrefslogtreecommitdiff
path: root/src/binfmt
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-18 13:33:19 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-18 13:33:22 +0200
commit741d2cb533cb939fe57f5a59f011961b407cf7f2 (patch)
tree305a835d2bb4a5f15865a8d4b9644f150135e076 /src/binfmt
parent7452c3ff525d23baf6dc723ad3342d289a3d5932 (diff)
downloadsystemd-741d2cb533cb939fe57f5a59f011961b407cf7f2.tar.gz
binfmt: fgets() excorcism
Also, let's not claim we ignored errors when we don't.
Diffstat (limited to 'src/binfmt')
-rw-r--r--src/binfmt/binfmt.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c
index 0e5ca1a7e8..fb8cf13f23 100644
--- a/src/binfmt/binfmt.c
+++ b/src/binfmt/binfmt.c
@@ -73,25 +73,25 @@ static int apply_file(const char *path, bool ignore_enoent) {
if (ignore_enoent && r == -ENOENT)
return 0;
- return log_error_errno(r, "Failed to open file '%s', ignoring: %m", path);
+ return log_error_errno(r, "Failed to open file '%s': %m", path);
}
log_debug("apply: %s", path);
for (;;) {
- char l[LINE_MAX], *p;
+ _cleanup_free_ char *line = NULL;
+ char *p;
int k;
- if (!fgets(l, sizeof(l), f)) {
- if (feof(f))
- break;
-
- return log_error_errno(errno, "Failed to read file '%s', ignoring: %m", path);
- }
+ k = read_line(f, LONG_LINE_MAX, &line);
+ if (k < 0)
+ return log_error_errno(k, "Failed to read file '%s': %m", path);
+ if (k == 0)
+ break;
- p = strstrip(l);
- if (!*p)
+ p = strstrip(line);
+ if (isempty(p))
continue;
- if (strchr(COMMENTS "\n", *p))
+ if (strchr(COMMENTS, p[0]))
continue;
k = apply_rule(p);