X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=sha1_file.c;h=54648282592d85cea0b1d42e02f358c240991ce2;hb=73136b2e8a8ee024320c5ac6a0f14f912432bf03;hp=ba8c4f76011c68548e959a17883b9a9d6cfbeeff;hpb=00cbdec981e186264dc2529edce31da4bcbd41f3;p=git.git diff --git a/sha1_file.c b/sha1_file.c index ba8c4f76..54648282 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -108,9 +108,10 @@ int safe_create_leading_directories(char *path) char * sha1_to_hex(const unsigned char *sha1) { - static char buffer[50]; + static int bufno; + static char hexbuffer[4][50]; static const char hex[] = "0123456789abcdef"; - char *buf = buffer; + char *buffer = hexbuffer[3 & ++bufno], *buf = buffer; int i; for (i = 0; i < 20; i++) { @@ -808,10 +809,12 @@ static int packed_delta_info(unsigned char *base_sha1, * the result size. */ data = delta_head; - get_delta_hdr_size(&data); /* ignore base size */ + + /* ignore base size */ + get_delta_hdr_size(&data, delta_head+sizeof(delta_head)); /* Read the result size */ - result_size = get_delta_hdr_size(&data); + result_size = get_delta_hdr_size(&data, delta_head+sizeof(delta_head)); *sizep = result_size; } return 0; @@ -872,17 +875,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;