X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=sha1_file.c;h=54648282592d85cea0b1d42e02f358c240991ce2;hb=0cc9e70c4c9adb3e79b4a492f2f989c611d85966;hp=e3d011309a610ad2b81eeabe810e3844e946734b;hpb=028e0491c07f8628d3c94ef01762ad695cc4efa3;p=git.git diff --git a/sha1_file.c b/sha1_file.c index e3d01130..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++) { @@ -874,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;