summaryrefslogtreecommitdiff
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
parent132b2771bbf29083ab51d8735de672cb530bc7af (diff)
sponge: Check fclose to detect certian short reads. Closes: #704453
-rw-r--r--debian/changelog1
-rw-r--r--sponge.c10
2 files changed, 9 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index 23a6beb..047e87d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,7 @@ moreutils (0.48) UNRELEASED; urgency=low
Thanks, Thomas Vander Stichele
* ts: Support single-digit day dates.
Thanks, Peter Lunicks
+ * sponge: Check fclose to detect certian short reads. Closes: #704453
-- Joey Hess <joeyh@debian.org> Wed, 25 Jul 2012 23:39:34 -0400
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) {