@matheusbsbs / matheus-bagliano / commits / 0d315468f3
Fork 0

sha1_file.c (write_sha1_from_fd): Detect close failure.

I stumbled across this in the context of the fchmod 0444 patch. At first, I was going to unlink and call error like the two subsequent tests do, but a failed write (above) provokes a "die", so I made this do the same. This is testing for a write failure, after all. Signed-off-by: Jim Meyering <jim@meyering.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jim Meyering committed Mar 26, 2007 at 15:57 UTC 0d315468f38729ebb15711349cece98a467032c9
1 file changed +2 -1
sha1_file.c
+2 -1
@@ -2155,7 +2155,8 @@ int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer,
2155 inflateEnd(&stream);
2156
2157 fchmod(local, 0444);
2158 - close(local);
2158 + if (close(local) != 0)
2159 + die("unable to write sha1 file");
2160 SHA1_Final(real_sha1, &c);
2161 if (ret != Z_STREAM_END) {
2162 unlink(tmpfile);