Mercurial > dovecot > original-hg > dovecot-1.2
changeset 43:526284657da7 HEAD
Fail if we try to mmap() files larger than 2G fully to memory
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 27 Aug 2002 05:27:05 +0300 |
parents | 1ab58549429d |
children | e399e33d033d |
files | src/lib/mmap-util.c |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/mmap-util.c Tue Aug 27 05:25:33 2002 +0300 +++ b/src/lib/mmap-util.c Tue Aug 27 05:27:05 2002 +0300 @@ -28,10 +28,19 @@ static void *mmap_file(int fd, size_t *length, int access) { - *length = lseek(fd, 0, SEEK_END); - if ((off_t)*length == -1) + off_t size; + + size = lseek(fd, 0, SEEK_END); + if (size == -1) return MAP_FAILED; + if (size > INT_MAX) { + /* too large file to map into memory */ + errno = EFBIG; + return MAP_FAILED; + } + + *length = (size_t)size; if (*length == 0) return NULL;