Skip to content

Commit 2855d58

Browse files
author
Junio C Hamano
committed
packed_object_info_detail(): check for corrupt packfile.
Serge E. Hallyn noticed that we compute how many input bytes are still left, but did not use it for sanity checking. Signed-off-by: Junio C Hamano <[email protected]>
1 parent bb99661 commit 2855d58

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

sha1_file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,17 +874,19 @@ void packed_object_info_detail(struct pack_entry *e,
874874
unsigned char *base_sha1)
875875
{
876876
struct packed_git *p = e->p;
877-
unsigned long offset, left;
877+
unsigned long offset;
878878
unsigned char *pack;
879879
enum object_type kind;
880880

881881
offset = unpack_object_header(p, e->offset, &kind, size);
882882
pack = p->pack_base + offset;
883-
left = p->pack_size - offset;
884883
if (kind != OBJ_DELTA)
885884
*delta_chain_length = 0;
886885
else {
887886
unsigned int chain_length = 0;
887+
if (p->pack_size <= offset + 20)
888+
die("pack file %s records an incomplete delta base",
889+
p->pack_name);
888890
memcpy(base_sha1, pack, 20);
889891
do {
890892
struct pack_entry base_ent;

0 commit comments

Comments
 (0)