diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-18 13:40:21 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-18 13:40:21 +0200 |
commit | a889e206a7434afe28039a1698e5ecf6a3fb7a9b (patch) | |
tree | a40c63d5c658629dc9b52ed31c0cf909e1e47e19 /src/modules-load | |
parent | 1d47b56995b7e9c0af836118bc51bed3945ceaf5 (diff) | |
download | systemd-a889e206a7434afe28039a1698e5ecf6a3fb7a9b.tar.gz systemd-a889e206a7434afe28039a1698e5ecf6a3fb7a9b.tar.bz2 systemd-a889e206a7434afe28039a1698e5ecf6a3fb7a9b.zip |
modules-load: fgets() excorcism
Diffstat (limited to 'src/modules-load')
-rw-r--r-- | src/modules-load/modules-load.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index bd4513b823..01d909ff19 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -72,25 +72,25 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent if (ignore_enoent && r == -ENOENT) return 0; - return log_error_errno(r, "Failed to open %s, ignoring: %m", path); + return log_error_errno(r, "Failed to open %s: %m", path); } log_debug("apply: %s", path); for (;;) { - char line[LINE_MAX], *l; + _cleanup_free_ char *line = NULL; + char *l; int k; - if (!fgets(line, sizeof(line), f)) { - if (feof(f)) - break; - - return log_error_errno(errno, "Failed to read file '%s', ignoring: %m", path); - } + r = read_line(f, LONG_LINE_MAX, &line); + if (r < 0) + return log_error_errno(errno, "Failed to read file '%s': %m", path); + if (r == 0) + break; l = strstrip(line); - if (!*l) + if (isempty(l)) continue; - if (strchr(COMMENTS "\n", *l)) + if (strchr(COMMENTS, *l)) continue; k = module_load_and_warn(ctx, l, true); |