SQLite

Check-in [46c3085dca]
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
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.414
Context
2017-08-07
18:27
Update bigmmap.test to account for builds that use "-DSQLITE_MAX_MMAP_SIZE=<integer-constant>LL". (check-in: 7c8b6f1cac 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: 46c3085dca user: dan tags: mmap-size-limit)
17:28
Fix an out-of-order test number. (check-in: 38f30091f9 user: mistachkin tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
3854
3855
3856
3857
3858
3859
3860







3861
3862
3863
3864
3865
3866
3867
#if SQLITE_MAX_MMAP_SIZE>0
    case SQLITE_FCNTL_MMAP_SIZE: {
      i64 newLimit = *(i64*)pArg;
      int rc = SQLITE_OK;
      if( newLimit>sqlite3GlobalConfig.mxMmap ){
        newLimit = sqlite3GlobalConfig.mxMmap;
      }







      *(i64*)pArg = pFile->mmapSizeMax;
      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
        pFile->mmapSizeMax = newLimit;
        if( pFile->mmapSize>0 ){
          unixUnmapfile(pFile);
          rc = unixMapfile(pFile, -1);
        }







>
>
>
>
>
>
>







3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
#if SQLITE_MAX_MMAP_SIZE>0
    case SQLITE_FCNTL_MMAP_SIZE: {
      i64 newLimit = *(i64*)pArg;
      int rc = SQLITE_OK;
      if( newLimit>sqlite3GlobalConfig.mxMmap ){
        newLimit = sqlite3GlobalConfig.mxMmap;
      }

      /* 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. */
      if( sizeof(size_t)<8 ){
        newLimit = (newLimit & 0x7FFFFFFF);
      }

      *(i64*)pArg = pFile->mmapSizeMax;
      if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
        pFile->mmapSizeMax = newLimit;
        if( pFile->mmapSize>0 ){
          unixUnmapfile(pFile);
          rc = unixMapfile(pFile, -1);
        }