]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a problem with the checksum-vfs and direct-overflow-reads. cksum-direct-ovfl-fix
authordan <Dan Kennedy>
Wed, 13 Aug 2025 14:35:14 +0000 (14:35 +0000)
committerdan <Dan Kennedy>
Wed, 13 Aug 2025 14:35:14 +0000 (14:35 +0000)
FossilOrigin-Name: 8288edb9f930206f117823cf1d18af632dc6adbd7c4c3b9bcfc252e1a5e5b9cd

ext/misc/cksumvfs.c
manifest
manifest.uuid
test/cksumvfs.test

index 2d7f6584ea1b48740ec0ec4be012bcf6617ca632..75b59f7998eea82fdac7fca136918256332d24fa 100644 (file)
@@ -433,6 +433,7 @@ static int cksmRead(
   pFile = ORIGFILE(pFile);
   rc = pFile->pMethods->xRead(pFile, zBuf, iAmt, iOfst);
   if( rc==SQLITE_OK ){
+    assert( iAmt==100 || (iAmt & (iAmt-1))==0 );
     if( iOfst==0 && iAmt>=100 && (
           memcmp(zBuf,"SQLite format 3",16)==0 || memcmp(zBuf,"ZV-",3)==0 
     )){
@@ -446,7 +447,7 @@ static int cksmRead(
     **    (2) checksum verification is enabled
     **    (3) we are not in the middle of checkpoint
     */
-    if( iAmt>=512 && (iAmt & (iAmt-1))==0   /* (1) */
+    if( iAmt>=512                           /* (1) */
      && p->verifyCksm                       /* (2) */
      && !p->inCkpt                          /* (3) */
     ){
@@ -611,8 +612,10 @@ static int cksmSectorSize(sqlite3_file *pFile){
 ** Return the device characteristic flags supported by a cksm-file.
 */
 static int cksmDeviceCharacteristics(sqlite3_file *pFile){
+  int devchar = 0;
   pFile = ORIGFILE(pFile);
-  return pFile->pMethods->xDeviceCharacteristics(pFile);
+  devchar = pFile->pMethods->xDeviceCharacteristics(pFile);
+  return (devchar & ~SQLITE_IOCAP_SUBPAGE_READ);
 }
 
 /* Create a shared memory file mapping */
index 92e539fb64c14604ffdc3bcdc5e25cb4dbd74801..97c9534b29b15572f4742c85ac051cb59d34d041 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\swith\sreading\swal\smode\sdatabases\sfrom\sUNC\sshares\son\swindows\sintroduced\sby\s[e88212b10a7829ff].
-D 2025-08-12T19:02:48.857
+C Fix\sa\sproblem\swith\sthe\schecksum-vfs\sand\sdirect-overflow-reads.
+D 2025-08-13T14:35:14.232
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -363,7 +363,7 @@ F ext/misc/blobio.c a867c4c4617f6ec223a307ebfe0eabb45e0992f74dd47722b96f3e631c0e
 F ext/misc/btreeinfo.c 8f5e6da2c82ec2f06ee0216e922370a436dafdbb06ffa7a552203515ff9e7ddf
 F ext/misc/carray.c 34fac63770971611c5285de0a9f0ac67d504eaf66be891f637add9290f1c76a5
 F ext/misc/carray.h 503209952ccf2431c7fd899ebb92bf46bf7635b38aace42ec8aa1b8d7b6e98a5
-F ext/misc/cksumvfs.c 3a7931dd30667be6348af919f3f9e6188dfd7646b42af8e399a499b327f5bd63
+F ext/misc/cksumvfs.c 077e7a556c2c79a0b4db3a5dc449cdf25541860f669f359e5bd965b6f5950649
 F ext/misc/closure.c 5559daf1daf742228431db929d1aa86dd535a4224cc634a81d2fd0d1e6ad7839
 F ext/misc/completion.c c3c8b3cc1293c34f04f8746a3adfbfedb43f00d113f8c984a1ed09433317e507
 F ext/misc/compress.c 2c79a74330e0e0ba6cb3f7397f8ba5af12d46377ef5d3ee075e12dd8a6ed57f0
@@ -962,7 +962,7 @@ F test/changes2.test 07949edcc732af28cb54276bfb7d99723bccc1e905a423648bf57ac5cb0
 F test/check.test 3a7972ccbaad80d496833da8714d69d9d5d4ce9e7211af1cd2a06ae488a7de12
 F test/checkfault.test da6cb3d50247169efcb20bdf57863a3ccfa1d27d9e55cd324f0680096970f014
 F test/chunksize.test faea11c5d6df9d392252a8dd879e1b1d68c9d3e8b7909cbed8bcec3b60c706f1
-F test/cksumvfs.test 6f05dc95847c06a3dc10eee6b5ab1351d78314a52d0db15717c9388f4cb96646
+F test/cksumvfs.test ec349149fbda923feb93e61a16674b6355b9ff6997f70c9e8f3b7843c51ea2af
 F test/close.test eccbad8ecd611d974cbf47278c3d4e5874faf02d811338d5d348af42d56d647c
 F test/closure01.test 9905883f1b171a4638f98fc764879f154e214a306d3d8daf412a15e7f3a9b1e0
 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91
@@ -2169,8 +2169,11 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh 1ad0169b022b280bcaaf94a7fa231591be96b514230ab5c98fbf15cd7df842dd
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P a836126bbec5c14432ed7fc7e9e6f8ebcd5dd1116d3ac8a9a0d25c8f62cc51fe 9e6fa73467892eb2333c0a94ca38b66b7cc0432326de93ff131ecde4c165114e
-R 18674a1a51901a5d53c84c6dfa4ba3a6
+P f341e7812984b41acd7dd2dd795a1716a8826af4326578dcdf7d7fdd55124ceb
+R b9d4e0e5e4c48c6c952ee9acefa6e446
+T *branch * cksum-direct-ovfl-fix
+T *sym-cksum-direct-ovfl-fix *
+T -sym-trunk *
 U dan
-Z 42097e4404b87bcc5b9a7240b577b022
+Z 9f158a654620ec4ede4ad36e3e26a390
 # Remove this line to create a well-formed Fossil manifest.
index a3ac013ed63e250d096f221e0cf9fd4d5b415138..fab24b0096c6c08ad1837d6dec7a4ebf5aa8fe67 100644 (file)
@@ -1 +1 @@
-f341e7812984b41acd7dd2dd795a1716a8826af4326578dcdf7d7fdd55124ceb
+8288edb9f930206f117823cf1d18af632dc6adbd7c4c3b9bcfc252e1a5e5b9cd
index 8c7bcf5511ac399ed616a6856dd75a9e4795efa0..7b1f007e93b6e1400cc8ad23b82a9199d659ead2 100644 (file)
@@ -17,17 +17,38 @@ set testprefix cksumvfs
 sqlite3_register_cksumvfs
 db close
 sqlite3 db test.db
+
 file_control_reservebytes db 8
+execsql {
+  PRAGMA page_size = 4096;
+}
 
 set text [db one "SELECT hex(randomblob(5000))"]
 
 do_execsql_test 1.0 {
-  CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
-  INSERT INTO t1 VALUES(1, $text);
+  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
+  INSERT INTO t1 VALUES(1, $text, NULL);
 }
 
 do_execsql_test 1.1 {
   SELECT * FROM t1;
-} [list 1 $text]
+} [list 1 $text {}]
+
+do_execsql_test 1.2 {
+  DELETE FROM t1;
+}
+
+do_test 1.3 {
+  execsql BEGIN
+  for {set ii 1500} {$ii < 10000} {incr ii} {
+    execsql { INSERT INTO t1 VALUES(NULL, randomblob(5000), randomblob($ii)) }
+  }
+  execsql COMMIT
+} {}
+
+do_execsql_test 1.4 {
+  SELECT count(b) FROM t1
+} {8500}
 
 finish_test
+