Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid potential integer overflow in Mmap.mmap (JuliaLang#41186)
There is a potential integer overflow in Mmap.mmap which can lead to an out-of-bounds access. The size of the memory-mapped array `len` is calculated as `prod(dims)`. If this multiplication overflows, the allocated size will be too small and accesses towards the end of the array will fail with e.g. a segfault or other errors. I noticed this when using `dims` taken from a binary file header in UInt32 format. To fix, use overflow-aware multiplication to determine the size of the mmapped array and throw an error in case of overflow.
- Loading branch information