@matheusbsbs / matheus-bagliano / commits / 2855d58079
Fork 0

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 <junkio@cox.net>

Junio C Hamano committed Apr 17, 2006 at 17:46 UTC 2855d58079cd56361879cc03f7c769409bb445e5
1 file changed +4 -2
sha1_file.c
+4 -2
@@ -874,17 +874,19 @@ void packed_object_info_detail(struct pack_entry *e,
874 unsigned char *base_sha1)
875 {
876 struct packed_git *p = e->p;
877 - unsigned long offset, left;
877 + unsigned long offset;
878 unsigned char *pack;
879 enum object_type kind;
880
881 offset = unpack_object_header(p, e->offset, &kind, size);
882 pack = p->pack_base + offset;
883 - left = p->pack_size - offset;
883 if (kind != OBJ_DELTA)
884 *delta_chain_length = 0;
885 else {
886 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);
890 memcpy(base_sha1, pack, 20);
891 do {
892 struct pack_entry base_ent;