| OLD | NEW |
| 1 # 2008 June 11 | 1 # 2008 June 11 |
| 2 # | 2 # |
| 3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
| 4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
| 5 # | 5 # |
| 6 # May you do good and not evil. | 6 # May you do good and not evil. |
| 7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
| 8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
| 9 # | 9 # |
| 10 #*********************************************************************** | 10 #*********************************************************************** |
| 11 # This file implements regression tests for SQLite library. | 11 # This file implements regression tests for SQLite library. |
| 12 # | 12 # |
| 13 # This file implements tests to make sure SQLite does not crash or | 13 # This file implements tests to make sure SQLite does not crash or |
| 14 # segfault if it sees a corrupt database file. It specifically focuses | 14 # segfault if it sees a corrupt database file. It specifically focuses |
| 15 # on corrupt cell offsets in a btree page. | 15 # on corrupt cell offsets in a btree page. |
| 16 # | 16 # |
| 17 # $Id: corrupt7.test,v 1.8 2009/08/10 10:18:08 danielk1977 Exp $ | 17 # $Id: corrupt7.test,v 1.8 2009/08/10 10:18:08 danielk1977 Exp $ |
| 18 | 18 |
| 19 set testdir [file dirname $argv0] | 19 set testdir [file dirname $argv0] |
| 20 source $testdir/tester.tcl | 20 source $testdir/tester.tcl |
| 21 | 21 |
| 22 # Do not use a codec for tests in this file, as the database file is |
| 23 # manipulated directly using tcl scripts (using the [hexio_write] command). |
| 24 # |
| 25 do_not_use_codec |
| 26 |
| 22 # We must have the page_size pragma for these tests to work. | 27 # We must have the page_size pragma for these tests to work. |
| 23 # | 28 # |
| 24 ifcapable !pager_pragmas { | 29 ifcapable !pager_pragmas { |
| 25 finish_test | 30 finish_test |
| 26 return | 31 return |
| 27 } | 32 } |
| 28 | 33 |
| 29 # Create a simple, small database. | 34 # Create a simple, small database. |
| 30 # | 35 # |
| 31 do_test corrupt7-1.1 { | 36 do_test corrupt7-1.1 { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 sqlite3 db test.db | 87 sqlite3 db test.db |
| 83 db eval {PRAGMA integrity_check(1)} | 88 db eval {PRAGMA integrity_check(1)} |
| 84 } {{*** in database main *** | 89 } {{*** in database main *** |
| 85 Corruption detected in cell 15 on page 2}} | 90 Corruption detected in cell 15 on page 2}} |
| 86 do_test corrupt7-2.2 { | 91 do_test corrupt7-2.2 { |
| 87 db close | 92 db close |
| 88 hexio_write test.db 1062 04 | 93 hexio_write test.db 1062 04 |
| 89 sqlite3 db test.db | 94 sqlite3 db test.db |
| 90 db eval {PRAGMA integrity_check(1)} | 95 db eval {PRAGMA integrity_check(1)} |
| 91 } {{*** in database main *** | 96 } {{*** in database main *** |
| 92 Corruption detected in cell 15 on page 2}} | 97 On tree page 2 cell 15: Rowid 0 out of order (previous was 15)}} |
| 93 } | 98 } |
| 94 | 99 |
| 95 # The code path that was causing the buffer overrun that this test | 100 # The code path that was causing the buffer overrun that this test |
| 96 # case was checking for was removed. | 101 # case was checking for was removed. |
| 97 # | 102 # |
| 98 #do_test corrupt7-3.1 { | 103 #do_test corrupt7-3.1 { |
| 99 # execsql { | 104 # execsql { |
| 100 # DROP TABLE t1; | 105 # DROP TABLE t1; |
| 101 # CREATE TABLE t1(a, b); | 106 # CREATE TABLE t1(a, b); |
| 102 # INSERT INTO t1 VALUES(1, 'one'); | 107 # INSERT INTO t1 VALUES(1, 'one'); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 116 # # reference invalid memory. | 121 # # reference invalid memory. |
| 117 # hexio_write test.db $cell_offset FFFF7F | 122 # hexio_write test.db $cell_offset FFFF7F |
| 118 # | 123 # |
| 119 # sqlite3 db test.db | 124 # sqlite3 db test.db |
| 120 # catchsql { | 125 # catchsql { |
| 121 # SELECT b FROM t1 WHERE b > 'o' AND b < 'p'; | 126 # SELECT b FROM t1 WHERE b > 'o' AND b < 'p'; |
| 122 # } | 127 # } |
| 123 #} {1 {database disk image is malformed}} | 128 #} {1 {database disk image is malformed}} |
| 124 | 129 |
| 125 finish_test | 130 finish_test |
| OLD | NEW |