From: danielk1977 Date: Mon, 7 Jul 2008 15:39:11 +0000 (+0000) Subject: Add a test case to test corruption discovered as part of the ptrmapPut() routine... X-Git-Tag: version-3.6.10~826 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b76b05dcc9f77843e42bf65c6a42f78a2949c0f;p=thirdparty%2Fsqlite.git Add a test case to test corruption discovered as part of the ptrmapPut() routine. (CVS 5351) FossilOrigin-Name: cbb9536fc4fb2419e0eb6f3a32c67eeb7a73da82 --- diff --git a/manifest b/manifest index e11eea7686..57015e4cb0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\sa\scouple\sof\sspecific\smalloc()\sfailures\sthat\swere\snot\stested\sbefore.\s(CVS\s5350) -D 2008-07-07T14:56:57 +C Add\sa\stest\scase\sto\stest\scorruption\sdiscovered\sas\spart\sof\sthe\sptrmapPut()\sroutine.\s(CVS\s5351) +D 2008-07-07T15:39:11 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 325dfac0a0dd1cb4d975f1ace6453157892e6042 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -242,7 +242,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6 F test/colmeta.test 087c42997754b8c648819832241daf724f813322 F test/conflict.test bb29b052c60a1f7eb6382be77902061d1f305318 F test/corrupt.test af069d971853dbe12af936910bfa49d92f7b16e9 -F test/corrupt2.test 8059c7354aaba91e7405b4503b79f456c816df8e +F test/corrupt2.test a18ee5991548fd0fc827beb438ac948e4423186a F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32 F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff F test/corrupt5.test 7796d5bdfe155ed824cee9dff371f49da237cfe0 @@ -598,7 +598,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 4e941f3d43556d8a503bb96e8a74451de36d243e -R 8496763a8cb86990b088e6240ee7b548 +P b96bcaa197519b5be89e1f6a1579f0e36fe2b644 +R 62ed2591820a7196cabbdd58b316eda9 U danielk1977 -Z 8849602edea289185a3f9e44a68a98e7 +Z 9bfe6f64ae089bbd94ec78786a0de466 diff --git a/manifest.uuid b/manifest.uuid index f10192f9e8..5091a953f1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b96bcaa197519b5be89e1f6a1579f0e36fe2b644 \ No newline at end of file +cbb9536fc4fb2419e0eb6f3a32c67eeb7a73da82 \ No newline at end of file diff --git a/test/corrupt2.test b/test/corrupt2.test index 515669154a..dbdfae8784 100644 --- a/test/corrupt2.test +++ b/test/corrupt2.test @@ -13,7 +13,7 @@ # This file implements tests to make sure SQLite does not crash or # segfault if it sees a corrupt database file. # -# $Id: corrupt2.test,v 1.5 2008/03/19 13:03:34 drh Exp $ +# $Id: corrupt2.test,v 1.6 2008/07/07 15:39:11 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -132,4 +132,45 @@ do_test corrupt2-2.1 { db2 close +do_test corrupt2-3.1 { + file delete -force corrupt.db + file delete -force corrupt.db-journal + sqlite3 db2 corrupt.db + + execsql { + PRAGMA auto_vacuum = 1; + PRAGMA page_size = 1024; + CREATE TABLE t1(a, b, c); + CREATE TABLE t2(a, b, c); + INSERT INTO t2 VALUES(randomblob(100), randomblob(100), randomblob(100)); + INSERT INTO t2 SELECT * FROM t2; + INSERT INTO t2 SELECT * FROM t2; + INSERT INTO t2 SELECT * FROM t2; + INSERT INTO t2 SELECT * FROM t2; + } db2 + + db2 close + + # On the root page of table t2 (page 4), set one of the child page-numbers + # to 0. This corruption will be detected when SQLite attempts to update + # the pointer-map after moving the content of page 4 to page 3 as part + # of the DROP TABLE operation below. + # + set fd [open corrupt.db r+] + fconfigure $fd -encoding binary -translation binary + seek $fd [expr 1024*3 + 12] + set zCelloffset [read $fd 2] + binary scan $zCelloffset S iCelloffset + seek $fd [expr 1024*3 + $iCelloffset] + puts -nonewline $fd "\00\00\00\00" + close $fd + + sqlite3 db2 corrupt.db + catchsql { + DROP TABLE t1; + } db2 +} {1 {malformed database schema (a3) - index a3 already exists}} + +db2 close + finish_test