From 6684c636fd26eab49eec25d0538b2fc4b5542924 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 2 Apr 2013 01:34:50 -0400 Subject: sponge: Check fclose to detect certian short reads. Closes: #704453 --- debian/changelog | 1 + sponge.c | 10 ++++++++-- 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 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) { -- cgit v1.2.3