Skip to content

Commit

Permalink
check_sha1_signature: check return value from read_istream
Browse files Browse the repository at this point in the history
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 <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 45d4bda commit f54fac5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,10 @@ int check_sha1_signature(const unsigned char *sha1, void *map,
char buf[1024 * 16];
ssize_t readlen = read_istream(st, buf, sizeof(buf));

if (readlen < 0) {
close_istream(st);
return -1;
}
if (!readlen)
break;
git_SHA1_Update(&c, buf, readlen);
Expand Down

0 comments on commit f54fac5

Please sign in to comment.