1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Test that a corrupted WAL hash-table does not put the library into an infinite loop.

FossilOrigin-Name: c73886ed7497c0daf798c3b02ca6f5a1c2addde3
This commit is contained in:
dan
2010-07-14 07:06:47 +00:00
parent b31a6afad0
commit c385793495
3 changed files with 55 additions and 7 deletions

View File

@ -1,5 +1,5 @@
C Fix\sa\stypo\sin\sthe\sIS_BIG_INT\smacro\sused\sby\scoverage\stest\sinstrumentation.
D 2010-07-14T06:20:27
C Test\sthat\sa\scorrupted\sWAL\shash-table\sdoes\snot\sput\sthe\slibrary\sinto\san\sinfinite\sloop.
D 2010-07-14T07:06:48
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -776,7 +776,7 @@ F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
F test/wal.test 1891e6f72dd437a1c2a48091aa9182ba17a8f780
F test/wal2.test f4e96e3b793cdc20a45031d3f1173e67f6cc44ec
F test/wal2.test 85775a7f68013f8734da8f5131c108e29cdbe868
F test/wal3.test d2ae7e66f973bd6b58ce49e546b2c00f44fe0485
F test/wal4.test 640be93f5422df37203aa5e7c06b24fb5e4a2439
F test/wal_common.tcl 895d76138043b86bdccf36494054bdabcf65837b
@ -834,7 +834,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 90d73c66bfa880cdeb688b3016c8b1c58bfcf35f
R d25f37ac17323937dfd921db79d60eda
P 5314ca3928dab1c76fa4ec5dbe110e3212c95e9f
R 0b5ec8b4983e94c7c92570f220ab5e66
U dan
Z ff2d33ba3ce5ee4d6c12121b51ff3660
Z 52c880220531a7798727e625d1f7aefa

View File

@ -1 +1 @@
5314ca3928dab1c76fa4ec5dbe110e3212c95e9f
c73886ed7497c0daf798c3b02ca6f5a1c2addde3

View File

@ -949,6 +949,54 @@ do_test wal2-10.2.3 {
set_tvfs_hdr $::filename $hdr
catchsql { SELECT * FROM t1 }
} {1 {unable to open database file}}
db close
tvfs delete
#-------------------------------------------------------------------------
# This block of tests - wal2-11.* - tests that it is not possible to put
# the library into an infinite loop by presenting it with a corrupt
# hash table (one that appears to contain a single chain of infinite
# length).
#
# wal2-11.1.*: While reading the hash-table.
#
# wal2-11.2.*: While writing the hash-table.
#
testvfs tvfs -default 1
do_test wal2-11.0 {
faultsim_delete_and_reopen
execsql {
PRAGMA journal_mode = WAL;
CREATE TABLE t1(a, b, c);
INSERT INTO t1 VALUES(1, 2, 3);
INSERT INTO t1 VALUES(4, 5, 6);
INSERT INTO t1 VALUES(7, 8, 9);
SELECT * FROM t1;
}
} {wal 1 2 3 4 5 6 7 8 9}
do_test wal2-11.1.1 {
sqlite3 db2 test.db
execsql { SELECT name FROM sqlite_master } db2
} {t1}
# Fill up the hash table on the first page of shared memory with 0x55 bytes.
#
set blob [string range [tvfs shm $::filename] 0 16383]
append blob [string repeat [binary format c 0x55] 16384]
tvfs shm $::filename $blob
do_test wal2-11.2 {
catchsql { SELECT * FROM t1 } db2
} {1 {database disk image is malformed}}
do_test wal2-12.1 {
catchsql { INSERT INTO t1 VALUES(10, 11, 12) }
} {1 {database disk image is malformed}}
db close
db2 close
tvfs delete
finish_test