summaryrefslogtreecommitdiff
path: root/pack-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'pack-write.c')
-rw-r--r--pack-write.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/pack-write.c b/pack-write.c
index 88bc7f9..c057513 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -304,7 +304,8 @@ char *index_pack_lockfile(int ip_out)
* - each byte afterwards: low seven bits are size continuation,
* with the high bit being "size continues"
*/
-int encode_in_pack_object_header(enum object_type type, uintmax_t size, unsigned char *hdr)
+int encode_in_pack_object_header(unsigned char *hdr, int hdr_len,
+ enum object_type type, uintmax_t size)
{
int n = 1;
unsigned char c;
@@ -315,6 +316,8 @@ int encode_in_pack_object_header(enum object_type type, uintmax_t size, unsigned
c = (type << 4) | (size & 15);
size >>= 4;
while (size) {
+ if (n == hdr_len)
+ die("object size is too enormous to format");
*hdr++ = c | 0x80;
c = size & 0x7f;
size >>= 7;