diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-03-28 14:05:59 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-28 14:05:59 -0700 |
commit | 53a0f9f7ad8cda231ce5bb15a0f086f29bdc6de3 (patch) | |
tree | be3fdc3c02d35634ef2471ff105e2750fe61aa4d /builtin | |
parent | f4948902923685134bc01292f2c97315eab6c82a (diff) | |
parent | 2c5e2865cc3dfc053e71510415f479e165119d04 (diff) | |
download | git-53a0f9f7ad8cda231ce5bb15a0f086f29bdc6de3.tar.gz |
Merge branch 'jk/fast-import-cleanup'
Code clean-up.
* jk/fast-import-cleanup:
pack.h: define largest possible encoded object size
encode_in_pack_object_header: respect output buffer length
fast-import: use xsnprintf for formatting headers
fast-import: use xsnprintf for writing sha1s
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/pack-objects.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 16517f2637..84af7c2324 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -239,7 +239,8 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent unsigned long limit, int usable_delta) { unsigned long size, datalen; - unsigned char header[10], dheader[10]; + unsigned char header[MAX_PACK_OBJECT_HEADER], + dheader[MAX_PACK_OBJECT_HEADER]; unsigned hdrlen; enum object_type type; void *buf; @@ -286,7 +287,8 @@ static unsigned long write_no_reuse_object(struct sha1file *f, struct object_ent * The object header is a byte of 'type' followed by zero or * more bytes of length. */ - hdrlen = encode_in_pack_object_header(type, size, header); + hdrlen = encode_in_pack_object_header(header, sizeof(header), + type, size); if (type == OBJ_OFS_DELTA) { /* @@ -352,13 +354,15 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry, off_t offset; enum object_type type = entry->type; off_t datalen; - unsigned char header[10], dheader[10]; + unsigned char header[MAX_PACK_OBJECT_HEADER], + dheader[MAX_PACK_OBJECT_HEADER]; unsigned hdrlen; if (entry->delta) type = (allow_ofs_delta && entry->delta->idx.offset) ? OBJ_OFS_DELTA : OBJ_REF_DELTA; - hdrlen = encode_in_pack_object_header(type, entry->size, header); + hdrlen = encode_in_pack_object_header(header, sizeof(header), + type, entry->size); offset = entry->in_pack_offset; revidx = find_pack_revindex(p, offset); |