]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fileio: write_string_stream_ts: return errors from fputs and fputc
authorMike Gilbert <floppym@gentoo.org>
Thu, 28 Dec 2017 02:46:52 +0000 (21:46 -0500)
committerMike Gilbert <floppym@gentoo.org>
Fri, 29 Dec 2017 13:45:30 +0000 (08:45 -0500)
Ignoring errors from these functions may mask errors returned by the
kernel.

Fixes: https://github.com/systemd/systemd/issues/7744
src/basic/fileio.c

index 4e02d5b3445b0d011499b52d9b021a3141dccbfd..21ea24d90f4b2714057e4c817f225b4c18ba3232 100644 (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};