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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Mar 25, 2013 at 16:17 UTC
f54fac53786808130c82936e59be16000deba04a
1 file changed
+4
sha1_file.c
+4
@@ -1266,6 +1266,10 @@ int check_sha1_signature(const unsigned char *sha1, void *map,
1266
char buf[1024 * 16];
1267
ssize_t readlen = read_istream(st, buf, sizeof(buf));
1268
1269
+ if (readlen < 0) {
1270
+ close_istream(st);
1271
+ return -1;
1272
+ }
1273
if (!readlen)
1274
break;
1275
git_SHA1_Update(&c, buf, readlen);