]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a valgrind error and potential buffer overread when handling a corrupt database.
authordrh <>
Tue, 21 Mar 2023 11:27:41 +0000 (11:27 +0000)
committerdrh <>
Tue, 21 Mar 2023 11:27:41 +0000 (11:27 +0000)
FossilOrigin-Name: cb8b34fa1aa8bbe756ad9cfd864f93f8b5a78948b2622aaa230d4db18b846a4f

manifest
manifest.uuid
src/where.c

index 0667806fca0f2a97e942e3c418bc112c0ab70ee2..8ed0b1590fde6e51884e8201f1fcfc7fbc6e6fab 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\scausing\sa\scursor\sto\sretain\san\sout-of-date\scell-info\scache\swhen\sprocessing\sa\sDISTINCT\squery\son\svalues\sthat\sare\sidentical\saccording\sto\stheir\scollation\ssequence,\sbut\sdifferent\son\sdisk.
-D 2023-03-20T15:50:40.868
+C Fix\sa\svalgrind\serror\sand\spotential\sbuffer\soverread\swhen\shandling\sa\scorrupt\sdatabase.
+D 2023-03-21T11:27:41.254
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -706,7 +706,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
 F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d
 F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
 F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
-F src/where.c 1c2fc433f59d933a31e35e49b161cc2837ad0b28a0c097b4105ff781d47daeb5
+F src/where.c a016443c4f4853175f939dd4658e236922b14f926f06c5ee60dedeb259684bda
 F src/whereInt.h e25203e5bfee149f5f1225ae0166cfb4f1e65490c998a024249e98bb0647377c
 F src/wherecode.c b82d0d33315e1526904b95155e55e61149c4462147668e1cc4567c812735eff1
 F src/whereexpr.c 16d1eefd95f69843b45aba6d04fe2b63fc4f51584dff85ae380f5c20718f3c75
@@ -2045,9 +2045,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P d5cd6c885b71b0939f5832fbb63bf800ae03dbbc2dc0f7beab1270133d414c54
-Q +1b3abc1daeac29714256b5a1d5a07a75dc986f1089054a8bee44a00583b7383a
-R fa66c1ca464a0878b0d78bf784d15014
+P b02811847cbb9c80ba886d3e84fc6a8048cde5c932405f50416baf6e0cbd78e9
+Q +b1e0cd6444d1f710e58129723b285cf1321679fa920fc2841492dcb489ab8b9d
+R c4cf251aa233d23fb9a69cd8193d8d80
 U drh
-Z a48ca77dbf14e8cb5797e2b61f34219c
+Z 981462934dc83a97536ff755d9c5c8b8
 # Remove this line to create a well-formed Fossil manifest.
index e8d2c88e459086123c5cd361a9483350a5f6249c..1df5a80836698a90b8f239462d77ecf8d0f4ceef 100644 (file)
@@ -1 +1 @@
-b02811847cbb9c80ba886d3e84fc6a8048cde5c932405f50416baf6e0cbd78e9
\ No newline at end of file
+cb8b34fa1aa8bbe756ad9cfd864f93f8b5a78948b2622aaa230d4db18b846a4f
\ No newline at end of file
index 74d90fc907813fbe80a3a69529ee91dbb2a4f062..448c9557637ada065739cbc60c303af3f6972561 100644 (file)
@@ -1514,6 +1514,7 @@ static int whereKeyStats(
   assert( pRec!=0 );
   assert( pIdx->nSample>0 );
   assert( pRec->nField>0 );
 
   /* Do a binary search to find the first sample greater than or equal
   ** to pRec. If pRec contains a single field, the set of samples to search
@@ -1559,7 +1560,12 @@ static int whereKeyStats(
   ** it is extended to two fields. The duplicates that this creates do not 
   ** cause any problems.
   */
-  nField = MIN(pRec->nField, pIdx->nSample);
+  if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
+    nField = pIdx->nKeyCol;
+  }else{
+    nField = pIdx->nColumn;
+  }
+  nField = MIN(pRec->nField, nField);
   iCol = 0;
   iSample = pIdx->nSample * nField;
   do{