Skip to content

Commit

Permalink
stream_blob_to_fd: detect errors reading from stream
Browse files Browse the repository at this point in the history
We call read_istream, but never check its return value for
errors. This can lead to us looping infinitely, as we just
keep trying to write "-1" bytes (and we do not notice the
error, as we simply check that write_in_full reports the
same number of bytes we fed it, which of course is also -1).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 27, 2013
1 parent 7632cd2 commit 45d4bda
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions streaming.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ int stream_blob_to_fd(int fd, unsigned const char *sha1, struct stream_filter *f
ssize_t wrote, holeto;
ssize_t readlen = read_istream(st, buf, sizeof(buf));

if (readlen < 0)
goto close_and_exit;
if (!readlen)
break;
if (can_seek && sizeof(buf) == readlen) {
Expand Down

0 comments on commit 45d4bda

Please sign in to comment.