Skip to content

Commit

Permalink
packed_object_info_detail(): check for corrupt packfile.
Browse files Browse the repository at this point in the history
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 <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Apr 18, 2006
1 parent bb99661 commit 2855d58
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,17 +874,19 @@ void packed_object_info_detail(struct pack_entry *e,
unsigned char *base_sha1)
{
struct packed_git *p = e->p;
unsigned long offset, left;
unsigned long offset;
unsigned char *pack;
enum object_type kind;

offset = unpack_object_header(p, e->offset, &kind, size);
pack = p->pack_base + offset;
left = p->pack_size - offset;
if (kind != OBJ_DELTA)
*delta_chain_length = 0;
else {
unsigned int chain_length = 0;
if (p->pack_size <= offset + 20)
die("pack file %s records an incomplete delta base",
p->pack_name);
memcpy(base_sha1, pack, 20);
do {
struct pack_entry base_ent;
Expand Down

0 comments on commit 2855d58

Please sign in to comment.