Skip to content

Commit 45d4bda

Browse files
peffgitster
authored andcommitted
stream_blob_to_fd: detect errors reading from stream
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7632cd2 commit 45d4bda

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

streaming.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ int stream_blob_to_fd(int fd, unsigned const char *sha1, struct stream_filter *f
514514
ssize_t wrote, holeto;
515515
ssize_t readlen = read_istream(st, buf, sizeof(buf));
516516

517+
if (readlen < 0)
518+
goto close_and_exit;
517519
if (!readlen)
518520
break;
519521
if (can_seek && sizeof(buf) == readlen) {

0 commit comments

Comments
 (0)