]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a usan complaint about signed integer overflow.
authordan <Dan Kennedy>
Fri, 22 Dec 2023 14:47:30 +0000 (14:47 +0000)
committerdan <Dan Kennedy>
Fri, 22 Dec 2023 14:47:30 +0000 (14:47 +0000)
FossilOrigin-Name: e65907e0279f4814ec957f0790777d8b94a86926cd27c52442b311b27efc0185

ext/fts5/fts5_index.c
ext/fts5/test/fts5secure3.test
manifest
manifest.uuid

index 8a77523f6d1ae72776bd443b22bd3882f612a922..3f88b2af4e731874a223e0b0bf1693885f3df1ea 100644 (file)
@@ -1547,9 +1547,9 @@ static int fts5DlidxLvlNext(Fts5DlidxLvl *pLvl){
     }
 
     if( iOff<pData->nn ){
-      i64 iVal;
+      u64 iVal;
       pLvl->iLeafPgno += (iOff - pLvl->iOff) + 1;
-      iOff += fts5GetVarint(&pData->p[iOff], (u64*)&iVal);
+      iOff += fts5GetVarint(&pData->p[iOff], &iVal);
       pLvl->iRowid += iVal;
       pLvl->iOff = iOff;
     }else{
index bc56e08200606c8371c18f3507ab461d506d497c..49347144f3b6cd831b81ef92c6be96d0b7fc0213 100644 (file)
@@ -86,71 +86,76 @@ do_execsql_test 2.8 {
 # Tests with large/small rowid values.
 #
 
-reset_db
-
-expr srand(0)
-
-set vocab {
-  Popper Poppins Popsicle Porfirio Porrima Porsche
-  Porter Portia Portland Portsmouth Portugal Portuguese
-  Poseidon Post PostgreSQL Potemkin Potomac Potsdam
-  Pottawatomie Potter Potts Pound Poussin Powell
-  PowerPC PowerPoint Powers Powhatan Poznan Prada
-  Prado Praetorian Prague Praia Prakrit Pratchett
-  Pratt Pravda Praxiteles Preakness Precambrian Preminger
-  Premyslid Prensa Prentice Pres Presbyterian Presbyterianism
-}
-proc newdoc {} {
-  for {set i 0} {$i<8} {incr i} {
-    lappend ret [lindex $::vocab [expr int(abs(rand()) * [llength $::vocab])]]
+foreach {tn cfg} {
+  1 ""
+  2 "INSERT INTO fff(fff, rank) VALUES('secure-delete', 1)"
+} {
+  reset_db
+  
+  expr srand(0)
+  
+  set vocab {
+    Popper Poppins Popsicle Porfirio Porrima Porsche
+    Porter Portia Portland Portsmouth Portugal Portuguese
+    Poseidon Post PostgreSQL Potemkin Potomac Potsdam
+    Pottawatomie Potter Potts Pound Poussin Powell
+    PowerPC PowerPoint Powers Powhatan Poznan Prada
+    Prado Praetorian Prague Praia Prakrit Pratchett
+    Pratt Pravda Praxiteles Preakness Precambrian Preminger
+    Premyslid Prensa Prentice Pres Presbyterian Presbyterianism
   }
-  set ret
-}
-db func newdoc newdoc
-
-do_execsql_test 3.0 {
-  CREATE VIRTUAL TABLE fff USING fts5(y);
-  INSERT INTO fff(fff, rank) VALUES('pgsz', 64);
-
-  WITH s(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM s WHERE x<1000 )
-  INSERT INTO fff(rowid, y) SELECT random() , newdoc() FROM s;
-
-  WITH s(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM s WHERE x<1000 )
-  INSERT INTO fff(rowid, y) SELECT random() , newdoc() FROM s;
-
-  WITH s(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM s WHERE x<1000 )
-  INSERT INTO fff(rowid, y) SELECT random() , newdoc() FROM s;
-
-  INSERT INTO fff(fff, rank) VALUES('secure-delete', 1);
-}
-
-proc lshuffle {in} {
-  set out [list]
-  while {[llength $in]>0} {
-    set idx [expr int(abs(rand()) * [llength $in])]
-    lappend out [lindex $in $idx]
-    set in [lreplace $in $idx $idx]
+  proc newdoc {} {
+    for {set i 0} {$i<8} {incr i} {
+      lappend ret [lindex $::vocab [expr int(abs(rand()) * [llength $::vocab])]]
+    }
+    set ret
+  }
+  db func newdoc newdoc
+  
+  do_execsql_test 3.$tn.0 {
+    CREATE VIRTUAL TABLE fff USING fts5(y);
+    INSERT INTO fff(fff, rank) VALUES('pgsz', 64);
+  
+    WITH s(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM s WHERE x<1000 )
+    INSERT INTO fff(rowid, y) SELECT random() , newdoc() FROM s;
+  
+    WITH s(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM s WHERE x<1000 )
+    INSERT INTO fff(rowid, y) SELECT random() , newdoc() FROM s;
+  
+    WITH s(x) AS ( VALUES(1) UNION ALL SELECT x+1 FROM s WHERE x<1000 )
+    INSERT INTO fff(rowid, y) SELECT random() , newdoc() FROM s;
   }
-  set out
-}
-
-#dump fff
 
-set iTest 1
-foreach ii [lshuffle [db eval {SELECT rowid FROM fff}]] {
-  #if {$iTest==1} { dump fff }
-  #if {$iTest==1} { breakpoint }
-  do_execsql_test 3.1.$iTest.$ii {
-    DELETE FROM fff WHERE rowid=$ii;
+  execsql $cfg
+  
+  proc lshuffle {in} {
+    set out [list]
+    while {[llength $in]>0} {
+      set idx [expr int(abs(rand()) * [llength $in])]
+      lappend out [lindex $in $idx]
+      set in [lreplace $in $idx $idx]
+    }
+    set out
   }
-  #if {$iTest==1} { dump fff }
-  if {($iTest % 20)==0} {
-    do_execsql_test 3.1.$iTest.$ii.ic {
-      INSERT INTO fff(fff) VALUES('integrity-check');
+  
+  #dump fff
+  
+  set iTest 1
+  foreach ii [lshuffle [db eval {SELECT rowid FROM fff}]] {
+    #if {$iTest==1} { dump fff }
+    #if {$iTest==1} { breakpoint }
+    do_execsql_test 3.$tn.1.$iTest.$ii {
+      DELETE FROM fff WHERE rowid=$ii;
+    }
+    #if {$iTest==1} { dump fff }
+    if {($iTest % 20)==0} {
+      do_execsql_test 3.$tn.1.$iTest.$ii.ic {
+        INSERT INTO fff(fff) VALUES('integrity-check');
+      }
     }
+    #if {$iTest==1} { break }
+    incr iTest
   }
-  #if {$iTest==1} { break }
-  incr iTest
 }
 
 #execsql_pp { SELECT rowid FROM fff('post') ORDER BY rowid ASC }
index 582dc6f8bd78096ad33ad0bc35219aa220eb4797..f89671a85dcd1bb0dc95d83b24d2090d6eedb8e8 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sa\snew\scomment\sto\sdebugging\soutput\sroutine\ssqlite3WhereLoopPrint()\sto\nremind\sus\sof\swhat\sthe\svarious\sfields\sof\sthe\sdebug\soutput\smean.\s\sNo\schanges\nto\scode.
-D 2023-12-22T12:57:49.653
+C Fix\sa\susan\scomplaint\sabout\ssigned\sinteger\soverflow.
+D 2023-12-22T14:47:30.926
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -97,7 +97,7 @@ F ext/fts5/fts5_buffer.c 0eec58bff585f1a44ea9147eae5da2447292080ea435957f7488c70
 F ext/fts5/fts5_config.c 8072a207034b51ae9b7694121d1b5715c794e94b275e088f70ae532378ca5cdf
 F ext/fts5/fts5_expr.c 248ecadbacdbeb85c433f907e57bb91224678c829e57ecf098e3543b5df8c3f9
 F ext/fts5/fts5_hash.c adda4272be401566a6e0ba1acbe70ee5cb97fce944bc2e04dc707152a0ec91b1
-F ext/fts5/fts5_index.c ed206045ff0f2226d870fa41fba45f738c0cc953ab74ba68477091b9a574ccd3
+F ext/fts5/fts5_index.c cf00132cf9c81e2be2e98f2c96d7c81de07935177e9868750b620c9bd843bb96
 F ext/fts5/fts5_main.c b908696c52410e8383019ac0657c8a5cd0c8f60e78edc169e9b3c4b93f24c933
 F ext/fts5/fts5_storage.c f9e31b0d155e9b2c92d5d3a09ad7a56b937fbf1c7f962e10f4ca6281349f3934
 F ext/fts5/fts5_tcl.c cf0fd0dbe64ec272491b749e0d594f563cda03336aeb60900129e6d18b0aefb8
@@ -211,7 +211,7 @@ F ext/fts5/test/fts5rowid.test b8790ec170a8dc1942a15aef3db926a5f3061b1ff17101300
 F ext/fts5/test/fts5savepoint.test 050796b24929325cdbbb2fbfe2794816ae95d298e940ae15032200c2f4a73725
 F ext/fts5/test/fts5secure.test a02f771742fb2b1b9bdcb4bf523bcf2d0aa1ff597831d40fe3e72aaa6d0ec40f
 F ext/fts5/test/fts5secure2.test 2e961d7eef939f294c56b5d895cac7f1c3a60b934ee2cfd5e5e620bdf1ba6bbc
-F ext/fts5/test/fts5secure3.test c7e1080a6912f2a3ac68f2e05b88b72a99de38543509b2bbf427cac5c9c1c610
+F ext/fts5/test/fts5secure3.test 6d066828d225b0dbe5db818d4d6165df7bb70210e68a577e858e8762400d5a23
 F ext/fts5/test/fts5secure4.test 0d10a80590c07891478700af7793b232962042677432b9846cf7fc8337b67c97
 F ext/fts5/test/fts5secure5.test c07a68ced5951567ac116c22f2d2aafae497e47fe9fcb6a335c22f9c7a4f2c3a
 F ext/fts5/test/fts5secure6.test 74bf04733cc523bccca519bb03d3b4e2ed6f6e3db7c59bf6be82c88a0ac857fd
@@ -2156,8 +2156,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 4d30478863b2a60512010de9ec6e3099bfaf75d4afee20acec536713fe94334d
-R bb6cc7c6adcae554d705e47acb1f531c
-U drh
-Z 17fb9a9e25ef316e762bdf861f70c582
+P da5f34fd4052432b1ae27bb12e56b358cdc5c1282653d60ed0f0fe62f727e4ee
+R 2c6195726c124c3dadd04ddbe5a976af
+U dan
+Z 5c86608ddefb4b77281d134add392a7d
 # Remove this line to create a well-formed Fossil manifest.
index 5eccf3624fd4e97e8320d6f48d71ade1866b3915..3d8c901bbc38550a28eb162639e2ce3a92f2eb60 100644 (file)
@@ -1 +1 @@
-da5f34fd4052432b1ae27bb12e56b358cdc5c1282653d60ed0f0fe62f727e4ee
\ No newline at end of file
+e65907e0279f4814ec957f0790777d8b94a86926cd27c52442b311b27efc0185
\ No newline at end of file