@matheusbsbs / matheus-bagliano / commits / 915308b187
Fork 0

avoid 31-bit truncation in write_loose_object

The size of the content we are adding may be larger than 2.1G (i.e., "git add gigantic-file"). Most of the code-path to do so uses size_t or unsigned long to record the size, but write_loose_object uses a signed int. On platforms where "int" is 32-bits (which includes x86_64 Linux platforms), we end up passing malloc a negative size. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jan 29, 2009 at 00:56 UTC 915308b187bdaba9ad1c6c3dea7b2b4b200b4796
1 file changed +2 -1
sha1_file.c
+2 -1
@@ -2280,7 +2280,8 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
2280 static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
2281 void *buf, unsigned long len, time_t mtime)
2282 {
2283 - int fd, size, ret;
2283 + int fd, ret;
2284 + size_t size;
2285 unsigned char *compressed;
2286 z_stream stream;
2287 char *filename;