]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
pg: check writing to a file was successful
authorSami Kerola <kerolasa@iki.fi>
Sat, 13 Apr 2013 19:54:41 +0000 (20:54 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 26 Apr 2013 11:26:06 +0000 (13:26 +0200)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
text-utils/pg.c

index c00b7371f3aaedded7659f32f86f80e8254f36ed..7ddf96bf98da35223c75086fea5000ecd0db7fcc 100644 (file)
@@ -1228,7 +1228,14 @@ static void pgfile(FILE *f, const char *name)
                                        /* No error check for compat. */
                                        fwrite_all(b, sizeof *b, sz, save);
                                }
-                               fclose(save);
+                               if (close_stream(save) != 0) {
+                                       cmd.count = errno;
+                                       mesg(_("write failed"));
+                                       mesg(": ");
+                                       mesg(p);
+                                       mesg(strerror(cmd.count));
+                                       goto newcmd;
+                               }
                                fseeko(fbuf, (off_t)0, SEEK_END);
                                mesg(_("saved"));
                                goto newcmd;