{"thread":{"id":"24560","subject":"[PATCH] xsize_t: check whether we lose bits","startedAt":"2010-07-28T16:36:31Z","lastAt":"2010-07-28T16:36:31Z","messageCount":1,"participants":["Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"146635","messageId":"a619b6d672b4d01ce4107566267ba9b67904652b.1280334553.git.trast@student.ethz.ch","threadId":"24560","inReplyTo":null,"subject":"[PATCH] xsize_t: check whether we lose bits","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-07-28T16:36:31Z","receivedAt":"2010-07-28T16:36:31Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Attempting to mmap (via git-add or similar) a file larger than 4GB on\n32-bit Linux systems results in a repository that has only the file\nmodulo 4GB stored, because of truncation of the off_t file size to a\nsize_t for mmap.\n\nWhen xsize_t was introduced to handle this truncation in dc49cd7 (Cast\n64 bit off_t to 32 bit size_t, 2007-03-06), Shawn even pointed out\nthat it should detect when such a cutoff happens.\n\nMake it so.\n\nSigned-off-by: Thomas Rast <trast@student.ethz.ch>\n---\n\nOf course this does not fix the underlying issue that we want to mmap\nthe file, so you still cannot add them.\n\nAlso, I must be missing something, this patch is way too simple.\n\n\n git-compat-util.h |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 02a73ee..fe845ae 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -388,6 +388,8 @@ extern int odb_pack_keep(char *name, size_t namesz, unsigned char *sha1);\n \n static inline size_t xsize_t(off_t len)\n {\n+\tif (len > (size_t) len)\n+\t\tdie(\"Cannot handle files this big\");\n \treturn (size_t)len;\n }\n \n-- \n1.7.2.349.gd5452\n"}]}