зеркало из https://github.com/microsoft/git.git
xsize_t: check whether we lose bits
Attempting to mmap (via git-add or similar) a file larger than 4GB on
32-bit Linux systems results in a repository that has only the file
modulo 4GB stored, because of truncation of the off_t file size to a
size_t for mmap.
When xsize_t was introduced to handle this truncation in dc49cd7
(Cast
64 bit off_t to 32 bit size_t, 2007-03-06), Shawn even pointed out
that it should detect when such a cutoff happens.
Make it so.
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
dc49cd769b
Коммит
46be82dfd0
|
@ -260,6 +260,8 @@ static inline ssize_t xwrite(int fd, const void *buf, size_t len)
|
|||
|
||||
static inline size_t xsize_t(off_t len)
|
||||
{
|
||||
if (len > (size_t) len)
|
||||
die("Cannot handle files this big");
|
||||
return (size_t)len;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче