summaryrefslogtreecommitdiff
path: root/sponge.c
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2013-04-02 01:34:50 -0400
committerJoey Hess <joey@kitenet.net>2013-04-02 01:34:50 -0400
commit6684c636fd26eab49eec25d0538b2fc4b5542924 (patch)
treee5e6f43c062f4c0306d8776c14d5ceb811470187 /sponge.c
parent132b2771bbf29083ab51d8735de672cb530bc7af (diff)
downloadmoreutils-6684c636fd26eab49eec25d0538b2fc4b5542924.tar.gz
sponge: Check fclose to detect certian short reads. Closes: #704453
Diffstat (limited to 'sponge.c')
-rw-r--r--sponge.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sponge.c b/sponge.c
index 62b3ab5..969703f 100644
--- a/sponge.c
+++ b/sponge.c
@@ -222,8 +222,14 @@ static void copy_tmpfile (FILE *tmpfile, FILE *outfile, char *buf, size_t size)
fclose(tmpfile);
exit(1);
}
- fclose(tmpfile);
- fclose(outfile);
+ if (fclose(tmpfile) != 0) {
+ perror("read temporary file");
+ exit(1);
+ }
+ if (fclose(outfile) != 0) {
+ perror("error writing buffer to output file");
+ exit(1);
+ }
}
FILE *open_tmpfile (void) {