Index: src/btree.c ================================================================== --- src/btree.c +++ src/btree.c @@ -7,11 +7,11 @@ ** 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. ** ************************************************************************* -** $Id: btree.c,v 1.623 2009/06/09 11:34:11 danielk1977 Exp $ +** $Id: btree.c,v 1.624 2009/06/09 13:42:25 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. ** Including a description of file format and an overview of operation. */ @@ -1151,11 +1151,11 @@ ** ** The following block of code checks early to see if a cell extends ** past the end of a page boundary and causes SQLITE_CORRUPT to be ** returned if it does. */ -#if defined(SQLITE_OVERREAD_CHECK) +#if defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK) { int iCellFirst; /* First allowable cell index */ int iCellLast; /* Last possible cell index */ int i; /* Index into the cell pointer array */ int sz; /* Size of a cell */ Index: src/test_config.c ================================================================== --- src/test_config.c +++ src/test_config.c @@ -14,11 +14,11 @@ ** None of the code in this file goes into a deliverable build. ** ** The focus of this file is providing the TCL testing layer ** access to compile-time constants. ** -** $Id: test_config.c,v 1.48 2009/03/16 13:19:36 danielk1977 Exp $ +** $Id: test_config.c,v 1.49 2009/06/09 13:42:25 drh Exp $ */ #include "sqliteLimit.h" #include "sqliteInt.h" @@ -174,10 +174,20 @@ #ifdef SQLITE_ENABLE_COLUMN_METADATA Tcl_SetVar2(interp, "sqlite_options", "columnmetadata", "1", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "columnmetadata", "0", TCL_GLOBAL_ONLY); #endif + +#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK + Tcl_SetVar2(interp, "sqlite_options", "oversize_cell_check", "1", + TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "oversize_cell_check", "0", + TCL_GLOBAL_ONLY); +#endif + + #ifdef SQLITE_OMIT_COMPLETE Tcl_SetVar2(interp, "sqlite_options", "complete", "0", TCL_GLOBAL_ONLY); #else Tcl_SetVar2(interp, "sqlite_options", "complete", "1", TCL_GLOBAL_ONLY); Index: test/corrupt7.test ================================================================== --- test/corrupt7.test +++ test/corrupt7.test @@ -12,11 +12,11 @@ # # This file implements tests to make sure SQLite does not crash or # segfault if it sees a corrupt database file. It specifically focuses # on corrupt cell offsets in a btree page. # -# $Id: corrupt7.test,v 1.6 2009/06/04 17:02:51 drh Exp $ +# $Id: corrupt7.test,v 1.7 2009/06/09 13:42:25 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # We must have the page_size pragma for these tests to work. @@ -55,25 +55,45 @@ integrity_check corrupt7-1.4 # Deliberately corrupt some of the cell offsets in the btree page # on page 2 of the database. # -do_test corrupt7-2.1 { - db close - hexio_write test.db 1062 FF - sqlite3 db test.db - db eval {PRAGMA integrity_check(1)} -} {{*** in database main *** +# The error message is different depending on whether or not the +# SQLITE_ENABLE_OVERSIZE_CELL_CHECK compile-time option is engaged. +# +ifcapable oversize_cell_check { + do_test corrupt7-2.1 { + db close + hexio_write test.db 1062 FF + sqlite3 db test.db + db eval {PRAGMA integrity_check(1)} + } {{*** in database main *** Page 2: sqlite3BtreeInitPage() returns error code 11}} -do_test corrupt7-2.2 { - db close - hexio_write test.db 1062 04 - sqlite3 db test.db - db eval {PRAGMA integrity_check(1)} -} {{*** in database main *** + do_test corrupt7-2.2 { + db close + hexio_write test.db 1062 04 + sqlite3 db test.db + db eval {PRAGMA integrity_check(1)} + } {{*** in database main *** Page 2: sqlite3BtreeInitPage() returns error code 11}} - +} else { + do_test corrupt7-2.1 { + db close + hexio_write test.db 1062 FF + sqlite3 db test.db + db eval {PRAGMA integrity_check(1)} + } {{*** in database main *** +Corruption detected in cell 15 on page 2}} + do_test corrupt7-2.2 { + db close + hexio_write test.db 1062 04 + sqlite3 db test.db + db eval {PRAGMA integrity_check(1)} + } {{*** in database main *** +Corruption detected in cell 15 on page 2}} +} + # The code path that was causing the buffer overrun that this test # case was checking for was removed. # #do_test corrupt7-3.1 { # execsql {