Skip to content

Commit 97026fe

Browse files
committed
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 <[email protected]>
1 parent e568e56 commit 97026fe

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

streaming.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,17 +337,17 @@ static open_method_decl(loose)
337337
st->u.loose.mapped = map_sha1_file(sha1, &st->u.loose.mapsize);
338338
if (!st->u.loose.mapped)
339339
return -1;
340-
if (unpack_sha1_header(&st->z,
341-
st->u.loose.mapped,
342-
st->u.loose.mapsize,
343-
st->u.loose.hdr,
344-
sizeof(st->u.loose.hdr)) < 0) {
340+
if ((unpack_sha1_header(&st->z,
341+
st->u.loose.mapped,
342+
st->u.loose.mapsize,
343+
st->u.loose.hdr,
344+
sizeof(st->u.loose.hdr)) < 0) ||
345+
(parse_sha1_header(st->u.loose.hdr, &st->size) < 0)) {
345346
git_inflate_end(&st->z);
346347
munmap(st->u.loose.mapped, st->u.loose.mapsize);
347348
return -1;
348349
}
349350

350-
parse_sha1_header(st->u.loose.hdr, &st->size);
351351
st->u.loose.hdr_used = strlen(st->u.loose.hdr) + 1;
352352
st->u.loose.hdr_avail = st->z.total_out;
353353
st->z_state = z_used;

0 commit comments

Comments
 (0)