pack.h: define largest possible encoded object size
Several callers use fixed buffers for storing the pack object header, and they've picked 10 as a magic number. This is reasonable, since it handles objects up to 2^67. But let's give them a constant so it's clear that the number isn't pulled out of thin air. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7202a6fa87
commit
2c5e2865cc
@ -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 limit, int usable_delta)
|
||||||
{
|
{
|
||||||
unsigned long size, datalen;
|
unsigned long size, datalen;
|
||||||
unsigned char header[10], dheader[10];
|
unsigned char header[MAX_PACK_OBJECT_HEADER],
|
||||||
|
dheader[MAX_PACK_OBJECT_HEADER];
|
||||||
unsigned hdrlen;
|
unsigned hdrlen;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
void *buf;
|
void *buf;
|
||||||
@ -353,7 +354,8 @@ static off_t write_reuse_object(struct sha1file *f, struct object_entry *entry,
|
|||||||
off_t offset;
|
off_t offset;
|
||||||
enum object_type type = entry->type;
|
enum object_type type = entry->type;
|
||||||
off_t datalen;
|
off_t datalen;
|
||||||
unsigned char header[10], dheader[10];
|
unsigned char header[MAX_PACK_OBJECT_HEADER],
|
||||||
|
dheader[MAX_PACK_OBJECT_HEADER];
|
||||||
unsigned hdrlen;
|
unsigned hdrlen;
|
||||||
|
|
||||||
if (entry->delta)
|
if (entry->delta)
|
||||||
|
6
pack.h
6
pack.h
@ -84,6 +84,12 @@ extern int verify_pack(struct packed_git *, verify_fn fn, struct progress *, uin
|
|||||||
extern off_t write_pack_header(struct sha1file *f, uint32_t);
|
extern off_t write_pack_header(struct sha1file *f, uint32_t);
|
||||||
extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t, unsigned char *, off_t);
|
extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t, unsigned char *, off_t);
|
||||||
extern char *index_pack_lockfile(int fd);
|
extern char *index_pack_lockfile(int fd);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The "hdr" output buffer should be at least this big, which will handle sizes
|
||||||
|
* up to 2^67.
|
||||||
|
*/
|
||||||
|
#define MAX_PACK_OBJECT_HEADER 10
|
||||||
extern int encode_in_pack_object_header(unsigned char *hdr, int hdr_len,
|
extern int encode_in_pack_object_header(unsigned char *hdr, int hdr_len,
|
||||||
enum object_type, uintmax_t);
|
enum object_type, uintmax_t);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user