]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Avoid spurious SQLITE_IOERR_DATA errors when reading partial pages from a cksumvfs...
authordan <Dan Kennedy>
Mon, 18 Mar 2024 20:52:45 +0000 (20:52 +0000)
committerdan <Dan Kennedy>
Mon, 18 Mar 2024 20:52:45 +0000 (20:52 +0000)
FossilOrigin-Name: 0f485dbece9146eabe5a5c0998a9e35c685a170c3fe6d4509e92aa8dae18a2c0

ext/misc/cksumvfs.c
manifest
manifest.uuid
test/cksumvfs.test [new file with mode: 0644]

index e7c2c9d5c07b5ff674d0bb7b03a28c98bd80b1c8..2d7f6584ea1b48740ec0ec4be012bcf6617ca632 100644 (file)
@@ -446,9 +446,9 @@ static int cksmRead(
     **    (2) checksum verification is enabled
     **    (3) we are not in the middle of checkpoint
     */
-    if( iAmt>=512           /* (1) */
-     && p->verifyCksm       /* (2) */
-     && !p->inCkpt          /* (3) */
+    if( iAmt>=512 && (iAmt & (iAmt-1))==0   /* (1) */
+     && p->verifyCksm                       /* (2) */
+     && !p->inCkpt                          /* (3) */
     ){
       u8 cksum[8];
       cksmCompute((u8*)zBuf, iAmt-8, cksum);
index 68196a51d6681f7fcb4cc1ef6d6d8081042d0f7b..e0127ab6bdbf7e5304612e900f31ca31e6c80743 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sunnecessary\sblank\slines\sfrom\sbuild\scommands\sin\sthe\sdefault\sMakefile.in.
-D 2024-03-18T18:03:17.115
+C Avoid\sspurious\sSQLITE_IOERR_DATA\serrors\swhen\sreading\spartial\spages\sfrom\sa\scksumvfs\sdatabase\susing\sa\sSQLITE_DIRECT_OVERFLOW_READ\sbuild.
+D 2024-03-18T20:52:45.827
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -382,7 +382,7 @@ F ext/misc/blobio.c a867c4c4617f6ec223a307ebfe0eabb45e0992f74dd47722b96f3e631c0e
 F ext/misc/btreeinfo.c cb952620eedf5c0b7625b678f0f08e54d2ec0011d4e50efda5ebdc97f3df7d04
 F ext/misc/carray.c 34fac63770971611c5285de0a9f0ac67d504eaf66be891f637add9290f1c76a5
 F ext/misc/carray.h 503209952ccf2431c7fd899ebb92bf46bf7635b38aace42ec8aa1b8d7b6e98a5
-F ext/misc/cksumvfs.c 9224e33cc0cb6aa61ff1d7d7b8fd6fe56beca9f9c47954fa4ae0a69bef608f69
+F ext/misc/cksumvfs.c 3a7931dd30667be6348af919f3f9e6188dfd7646b42af8e399a499b327f5bd63
 F ext/misc/closure.c 0e04f52d93e678dd6f950f195f365992edf3c380df246f3d80425cba4c13891e
 F ext/misc/completion.c ef78835483b43ac18c96be312b90b615d8368189909be03513ab7a9338131298
 F ext/misc/compress.c 3354c77a7c8e86e07d849916000cdac451ed96500bfb5bd83b20eb61eee012c9
@@ -977,6 +977,7 @@ F test/changes2.test 07949edcc732af28cb54276bfb7d99723bccc1e905a423648bf57ac5cb0
 F test/check.test 56e4ed457e9f8683b9fc56f5b964f461f6e8a8dd5a13f3d495408215d66419ed
 F test/checkfault.test da6cb3d50247169efcb20bdf57863a3ccfa1d27d9e55cd324f0680096970f014
 F test/chunksize.test 427d87791743486cbf0c3b8c625002f3255cb3a89c6eba655a98923b1387b760
+F test/cksumvfs.test 6f05dc95847c06a3dc10eee6b5ab1351d78314a52d0db15717c9388f4cb96646
 F test/close.test eccbad8ecd611d974cbf47278c3d4e5874faf02d811338d5d348af42d56d647c
 F test/closure01.test 9905883f1b171a4638f98fc764879f154e214a306d3d8daf412a15e7f3a9b1e0
 F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91
@@ -2179,8 +2180,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 a120c9235f125e05be494038c16a9dd326fd79837698bef17e7879cd0cd75831
-R 8ff4324227d383f5da29d0bfe203141e
-U drh
-Z 25814839eb089de12c64c949b849b19e
+P 76fb3a908f45230b956cb659c754e47603e80aa72a2aad50d479437a9c013f61
+R 3ba9b9e82b0006578500d53bc7e1cee3
+U dan
+Z 687b3a53beb157acf8ccda89bb48f5f1
 # Remove this line to create a well-formed Fossil manifest.
index 73c10f1cd58da012650dad4668e66f29073906f8..e1416326912d795655bcb673984a4d325accf156 100644 (file)
@@ -1 +1 @@
-76fb3a908f45230b956cb659c754e47603e80aa72a2aad50d479437a9c013f61
\ No newline at end of file
+0f485dbece9146eabe5a5c0998a9e35c685a170c3fe6d4509e92aa8dae18a2c0
\ No newline at end of file
diff --git a/test/cksumvfs.test b/test/cksumvfs.test
new file mode 100644 (file)
index 0000000..8c7bcf5
--- /dev/null
@@ -0,0 +1,33 @@
+# 2024 March 19
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix cksumvfs
+
+sqlite3_register_cksumvfs
+db close
+sqlite3 db test.db
+file_control_reservebytes db 8
+
+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);
+}
+
+do_execsql_test 1.1 {
+  SELECT * FROM t1;
+} [list 1 $text]
+
+finish_test