aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/os_unix.c3
-rw-r--r--src/os_win.c8
2 files changed, 10 insertions, 1 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 3daa8fec9..d1ebd81f6 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -3860,7 +3860,8 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
}
/* The value of newLimit may be eventually cast to (size_t) and passed
- ** to mmap(). Restrict its value to 2GB if (size_t) is a 32-bit type. */
+ ** to mmap(). Restrict its value to 2GB if (size_t) is not at least a
+ ** 64-bit type. */
if( newLimit>0 && sizeof(size_t)<8 ){
newLimit = (newLimit & 0x7FFFFFFF);
}
diff --git a/src/os_win.c b/src/os_win.c
index a87d7d092..7045448fe 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -3559,6 +3559,14 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
if( newLimit>sqlite3GlobalConfig.mxMmap ){
newLimit = sqlite3GlobalConfig.mxMmap;
}
+
+ /* The value of newLimit may be eventually cast to (SIZE_T) and passed
+ ** to MapViewOfFile(). Restrict its value to 2GB if (SIZE_T) is not at
+ ** least a 64-bit type. */
+ if( newLimit>0 && sizeof(SIZE_T)<8 ){
+ newLimit = (newLimit & 0x7FFFFFFF);
+ }
+
*(i64*)pArg = pFile->mmapSizeMax;
if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
pFile->mmapSizeMax = newLimit;