| 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 #*********************************************************************** |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 hexio_get_int [hexio_read test.db 16 2] | 58 hexio_get_int [hexio_read test.db 16 2] |
| 59 } 1024 ;# The page size is 1024 | 59 } 1024 ;# The page size is 1024 |
| 60 do_test corrupt7-1.3 { | 60 do_test corrupt7-1.3 { |
| 61 hexio_get_int [hexio_read test.db 20 1] | 61 hexio_get_int [hexio_read test.db 20 1] |
| 62 } 0 ;# Unused bytes per page is 0 | 62 } 0 ;# Unused bytes per page is 0 |
| 63 | 63 |
| 64 integrity_check corrupt7-1.4 | 64 integrity_check corrupt7-1.4 |
| 65 | 65 |
| 66 # Deliberately corrupt some of the cell offsets in the btree page | 66 # Deliberately corrupt some of the cell offsets in the btree page |
| 67 # on page 2 of the database. | 67 # on page 2 of the database. |
| 68 # | 68 do_test corrupt7-2.1 { |
| 69 # The error message is different depending on whether or not the | 69 db close |
| 70 # SQLITE_ENABLE_OVERSIZE_CELL_CHECK compile-time option is engaged. | 70 hexio_write test.db 1062 FF |
| 71 # | 71 sqlite3 db test.db |
| 72 ifcapable oversize_cell_check { | 72 db eval {PRAGMA integrity_check(1)} |
| 73 do_test corrupt7-2.1 { | 73 } {{*** in database main *** |
| 74 db close | 74 On tree page 2 cell 15: Offset 65457 out of range 945..1020}} |
| 75 hexio_write test.db 1062 FF | 75 do_test corrupt7-2.2 { |
| 76 sqlite3 db test.db | 76 db close |
| 77 db eval {PRAGMA integrity_check(1)} | 77 hexio_write test.db 1062 04 |
| 78 } {{*** in database main *** | 78 sqlite3 db test.db |
| 79 Page 2: btreeInitPage() returns error code 11}} | 79 db eval {PRAGMA integrity_check(1)} |
| 80 do_test corrupt7-2.2 { | 80 } {{*** in database main *** |
| 81 db close | 81 On tree page 2 cell 15: Offset 1201 out of range 945..1020}} |
| 82 hexio_write test.db 1062 04 | |
| 83 sqlite3 db test.db | |
| 84 db eval {PRAGMA integrity_check(1)} | |
| 85 } {{*** in database main *** | |
| 86 Page 2: btreeInitPage() returns error code 11}} | |
| 87 } else { | |
| 88 do_test corrupt7-2.1 { | |
| 89 db close | |
| 90 hexio_write test.db 1062 FF | |
| 91 sqlite3 db test.db | |
| 92 db eval {PRAGMA integrity_check(1)} | |
| 93 } {{*** in database main *** | |
| 94 Corruption detected in cell 15 on page 2}} | |
| 95 do_test corrupt7-2.2 { | |
| 96 db close | |
| 97 hexio_write test.db 1062 04 | |
| 98 sqlite3 db test.db | |
| 99 db eval {PRAGMA integrity_check(1)} | |
| 100 } {{*** in database main *** | |
| 101 On tree page 2 cell 15: Rowid 0 out of order (previous was 15)}} | |
| 102 } | |
| 103 | 82 |
| 104 # The code path that was causing the buffer overrun that this test | 83 # The code path that was causing the buffer overrun that this test |
| 105 # case was checking for was removed. | 84 # case was checking for was removed. |
| 106 # | 85 # |
| 107 #do_test corrupt7-3.1 { | 86 #do_test corrupt7-3.1 { |
| 108 # execsql { | 87 # execsql { |
| 109 # DROP TABLE t1; | 88 # DROP TABLE t1; |
| 110 # CREATE TABLE t1(a, b); | 89 # CREATE TABLE t1(a, b); |
| 111 # INSERT INTO t1 VALUES(1, 'one'); | 90 # INSERT INTO t1 VALUES(1, 'one'); |
| 112 # INSERT INTO t1 VALUES(100, 'one hundred'); | 91 # INSERT INTO t1 VALUES(100, 'one hundred'); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 125 # # reference invalid memory. | 104 # # reference invalid memory. |
| 126 # hexio_write test.db $cell_offset FFFF7F | 105 # hexio_write test.db $cell_offset FFFF7F |
| 127 # | 106 # |
| 128 # sqlite3 db test.db | 107 # sqlite3 db test.db |
| 129 # catchsql { | 108 # catchsql { |
| 130 # SELECT b FROM t1 WHERE b > 'o' AND b < 'p'; | 109 # SELECT b FROM t1 WHERE b > 'o' AND b < 'p'; |
| 131 # } | 110 # } |
| 132 #} {1 {database disk image is malformed}} | 111 #} {1 {database disk image is malformed}} |
| 133 | 112 |
| 134 finish_test | 113 finish_test |
| OLD | NEW |