diff options
author | Jim Meyering <jim@meyering.net> | 2007-03-26 15:57:23 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-03-27 12:43:49 -0700 |
commit | 0d315468f38729ebb15711349cece98a467032c9 (patch) | |
tree | 40184f1d72e66267e82a570c7c27568cbba347fb /sha1_file.c | |
parent | e4d9516b2196623d927e232b4e8766269a837fe6 (diff) | |
download | git-0d315468f38729ebb15711349cece98a467032c9.tar.gz git-0d315468f38729ebb15711349cece98a467032c9.tar.xz |
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>
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c index 0897b945e..42aef331f 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2155,7 +2155,8 @@ int write_sha1_from_fd(const unsigned char *sha1, int fd, char *buffer, inflateEnd(&stream); fchmod(local, 0444); - close(local); + if (close(local) != 0) + die("unable to write sha1 file"); SHA1_Final(real_sha1, &c); if (ret != Z_STREAM_END) { unlink(tmpfile); |