/ Check-in [46c3085d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid casting a value larger than 2^31 to a (size_t) on systems where it is a 32-bit type.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | mmap-size-limit
Files: files | file ages | folders
SHA3-256: 46c3085dcad6372ac20eff499e17fe11680fdf4adb9186bf8b12221a5047e485
User & Date: dan 2017-08-07 18:13:28
Context
2017-08-07
18:27
Update bigmmap.test to account for builds that use "-DSQLITE_MAX_MMAP_SIZE=<integer-constant>LL". check-in: 7c8b6f1c user: dan tags: mmap-size-limit
18:13
Avoid casting a value larger than 2^31 to a (size_t) on systems where it is a 32-bit type. check-in: 46c3085d user: dan tags: mmap-size-limit
17:28
Fix an out-of-order test number. check-in: 38f30091 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

  3854   3854   #if SQLITE_MAX_MMAP_SIZE>0
  3855   3855       case SQLITE_FCNTL_MMAP_SIZE: {
  3856   3856         i64 newLimit = *(i64*)pArg;
  3857   3857         int rc = SQLITE_OK;
  3858   3858         if( newLimit>sqlite3GlobalConfig.mxMmap ){
  3859   3859           newLimit = sqlite3GlobalConfig.mxMmap;
  3860   3860         }
         3861  +
         3862  +      /* The value of newLimit may be eventually cast to (size_t) and passed
         3863  +      ** to mmap(). Restrict its value to 2GB if (size_t) is a 32-bit type. */
         3864  +      if( sizeof(size_t)<8 ){
         3865  +        newLimit = (newLimit & 0x7FFFFFFF);
         3866  +      }
         3867  +
  3861   3868         *(i64*)pArg = pFile->mmapSizeMax;
  3862   3869         if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
  3863   3870           pFile->mmapSizeMax = newLimit;
  3864   3871           if( pFile->mmapSize>0 ){
  3865   3872             unixUnmapfile(pFile);
  3866   3873             rc = unixMapfile(pFile, -1);
  3867   3874           }