Avoid casting a value larger than 2^31 to a (size_t) on systems where it

is a 32-bit type.

FossilOrigin-Name: 46c3085dcad6372ac20eff499e17fe11680fdf4adb9186bf8b12221a5047e485
This commit is contained in:
dan 2017-08-07 18:13:28 +00:00
parent 54640de156
commit 43c1e622cd
3 changed files with 15 additions and 8 deletions

View File

@ -1,5 +1,5 @@
C Fix\san\sout-of-order\stest\snumber.
D 2017-08-07T17:28:18.557
C Avoid\scasting\sa\svalue\slarger\sthan\s2^31\sto\sa\s(size_t)\son\ssystems\swhere\sit\n\sis\sa\s32-bit\stype.
D 2017-08-07T18:13:28.414
F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016
@ -436,7 +436,7 @@ F src/os.c add02933b1dce7a39a005b00a2f5364b763e9a24
F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
F src/os_unix.c 0681c6ef336fcb6a111f45b60a5faea38992ed6c4ae9fbd57a6f8e247724fa68
F src/os_unix.c bbe39b5921b7ced6d25fcbff9fd17eb4aa101fd0bd97e1db3c3e2d526527f9de
F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
F src/pager.c 1e63b0299cf123cf38c48413ec03190f56c1e7d0ccc6573c467d8ac240b898e9
@ -1644,7 +1644,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 17447062799239ee978bedbf7fcc67f4c7d2cad2e82dcf9349a966fc8f67d390
R ca41cbb6852190e871773e9cd0aff375
U mistachkin
Z 3adad62141c8f232faf24a8c8ab64143
P 38f30091f9b1e2c393396da7257f3487fa374e1ee6d610577291909768ff9626
R d7182bcc87ba6fa2b23f4b7d5a15d267
U dan
Z 7df27ce143e774d3022f4451dd6ffa24

View File

@ -1 +1 @@
38f30091f9b1e2c393396da7257f3487fa374e1ee6d610577291909768ff9626
46c3085dcad6372ac20eff499e17fe11680fdf4adb9186bf8b12221a5047e485

View File

@ -3858,6 +3858,13 @@ static int unixFileControl(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 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;