From: Sami Kerola Date: Sat, 13 Apr 2013 19:54:41 +0000 (+0100) Subject: pg: check writing to a file was successful X-Git-Tag: v2.24-rc1~598 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=944ab4b9316597d4a5616ff2c8d3f90cb1f3e9ad;p=thirdparty%2Futil-linux.git pg: check writing to a file was successful Signed-off-by: Sami Kerola --- diff --git a/text-utils/pg.c b/text-utils/pg.c index c00b7371f3..7ddf96bf98 100644 --- a/text-utils/pg.c +++ b/text-utils/pg.c @@ -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;