summaryrefslogtreecommitdiff
path: root/src/AbstractDiskWriter.cc
diff options
context:
space:
mode:
authorsuzker <szhiliang@gmail.com>2016-05-24 16:35:15 -0700
committersuzker <szhiliang@gmail.com>2016-05-24 16:37:31 -0700
commit43aea5c9402ff0a4c2bc8365ea9aa2ff3447a356 (patch)
tree9d526855303e18341fc4b7d06429ab153d52f797 /src/AbstractDiskWriter.cc
parent0b906f40f1204e79cb43af3867468ab02a371075 (diff)
added filesize overflow check for mmap on 32bit os
Diffstat (limited to 'src/AbstractDiskWriter.cc')
-rw-r--r--src/AbstractDiskWriter.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc
index 4d62bf97..df2d0a85 100644
--- a/src/AbstractDiskWriter.cc
+++ b/src/AbstractDiskWriter.cc
@@ -373,6 +373,14 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
return;
}
+ uint32_t filesize_lo = filesize & 0xffffffffu;
+ if (sizeof(off_t) > sizeof(size_t) && (filesize_lo) > 0) {
+ // filesize could overflow in 32bit OS with 64bit off_t type
+ // the filesize will be truncated if provided as a 32bit size_t
+ enableMmap_ = false;
+ return;
+ }
+
int errNum = 0;
if (static_cast<int64_t>(len + offset) <= filesize) {
#ifdef __MINGW32__