aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-09-28 13:34:05 +0000
committerdrh <drh@noemail.net>2020-09-28 13:34:05 +0000
commitf573b4fb94e5f40143916b72f1a42c1b1f3a72ee (patch)
treed643d5edff9ec9b2d4762a5fec7b139f3fc79555 /src
parent273ee151217b04c640c1af148e36c518678c89fa (diff)
downloadsqlite-f573b4fb94e5f40143916b72f1a42c1b1f3a72ee.tar.gz
sqlite-f573b4fb94e5f40143916b72f1a42c1b1f3a72ee.zip
Avoid the possibility of integer overflow on the --pagecache option to
the CLI. See [forum:10a2892377|forum post 10a2892377] FossilOrigin-Name: d3d13df31a97648f952beb2e1a783f947a80ec843227985ad9ebd14452d2f654
Diffstat (limited to 'src')
-rw-r--r--src/shell.c.in9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/shell.c.in b/src/shell.c.in
index 1e3a07fe4..0a827335c 100644
--- a/src/shell.c.in
+++ b/src/shell.c.in
@@ -10925,11 +10925,14 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
(void)cmdline_option_value(argc, argv, ++i);
#endif
}else if( strcmp(z,"-pagecache")==0 ){
- int n, sz;
- sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
+ sqlite3_int64 n, sz;
+ sz = integerValue(cmdline_option_value(argc,argv,++i));
if( sz>70000 ) sz = 70000;
if( sz<0 ) sz = 0;
- n = (int)integerValue(cmdline_option_value(argc,argv,++i));
+ n = integerValue(cmdline_option_value(argc,argv,++i));
+ if( sz>0 && n>0 && 0xffffffffffffLL/sz<n ){
+ n = 0xffffffffffffLL/sz;
+ }
sqlite3_config(SQLITE_CONFIG_PAGECACHE,
(n>0 && sz>0) ? malloc(n*sz) : 0, sz, n);
data.shellFlgs |= SHFLG_Pagecache;