diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-09-26 09:23:41 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-09-26 10:48:03 -0700 |
commit | 97026fe9a6f70b6c0a9e09408a504287c13dea43 (patch) | |
tree | 65df75365aa983251e470af557efbe296cffd648 | |
parent | Git 2.5.5 (diff) | |
download | tgif-97026fe9a6f70b6c0a9e09408a504287c13dea43.tar.xz |
streaming: make sure to notice corrupt object
The streaming read interface from a loose object called
parse_sha1_header() but discarded its return value, without noticing
a potential error.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | streaming.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/streaming.c b/streaming.c index 811fcc24d2..90feec9db6 100644 --- a/streaming.c +++ b/streaming.c @@ -337,17 +337,17 @@ static open_method_decl(loose) st->u.loose.mapped = map_sha1_file(sha1, &st->u.loose.mapsize); if (!st->u.loose.mapped) return -1; - if (unpack_sha1_header(&st->z, - st->u.loose.mapped, - st->u.loose.mapsize, - st->u.loose.hdr, - sizeof(st->u.loose.hdr)) < 0) { + if ((unpack_sha1_header(&st->z, + st->u.loose.mapped, + st->u.loose.mapsize, + st->u.loose.hdr, + sizeof(st->u.loose.hdr)) < 0) || + (parse_sha1_header(st->u.loose.hdr, &st->size) < 0)) { git_inflate_end(&st->z); munmap(st->u.loose.mapped, st->u.loose.mapsize); return -1; } - parse_sha1_header(st->u.loose.hdr, &st->size); st->u.loose.hdr_used = strlen(st->u.loose.hdr) + 1; st->u.loose.hdr_avail = st->z.total_out; st->z_state = z_used; |