Skip to content

Commit f54fac5

Browse files
peffgitster
authored andcommitted
check_sha1_signature: check return value from read_istream
It's possible for read_istream to return an error, in which case we just end up in an infinite loop (aside from EOF, we do not even look at the result, but just feed it straight into our running hash). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 45d4bda commit f54fac5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sha1_file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,10 @@ int check_sha1_signature(const unsigned char *sha1, void *map,
12661266
char buf[1024 * 16];
12671267
ssize_t readlen = read_istream(st, buf, sizeof(buf));
12681268

1269+
if (readlen < 0) {
1270+
close_istream(st);
1271+
return -1;
1272+
}
12691273
if (!readlen)
12701274
break;
12711275
git_SHA1_Update(&c, buf, readlen);

0 commit comments

Comments
 (0)