fileio: write_string_stream_ts: return errors from fputs and fputc

Ignoring errors from these functions may mask errors returned by the
kernel.

Fixes: https://github.com/systemd/systemd/issues/7744
This commit is contained in:
Mike Gilbert 2017-12-27 21:46:52 -05:00
parent d31eb24fc2
commit 94d3b60ff6
1 changed files with 5 additions and 2 deletions

View File

@ -65,9 +65,12 @@ int write_string_stream_ts(
assert(f);
assert(line);
fputs(line, f);
if (fputs(line, f) == EOF)
return -errno;
if (!(flags & WRITE_STRING_FILE_AVOID_NEWLINE) && !endswith(line, "\n"))
fputc('\n', f);
if (fputc('\n', f) == EOF)
return -errno;
if (ts) {
struct timespec twice[2] = {*ts, *ts};