1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Enable cell overflow checking in sqlite3BtreeInitPage() using the

compile-time option SQLITE_ENABLE_OVERSIZE_CELL_CHECK.  Change the tests
so that they recognize different error messages depending on the setting
of this macro. (CVS 6735)

FossilOrigin-Name: 56bff6eb2fc5f0afbd96afc986671ec744bd40e1
This commit is contained in:
drh
2009-06-09 13:42:24 +00:00
parent 80929b3de9
commit 3b2a3fa42e
5 changed files with 57 additions and 27 deletions

View File

@@ -1,5 +1,5 @@
C Avoid\scalling\sfillInCell()\sto\screate\san\sinternal\snode\sintkey\scell\sfrom\sbalance_nonroot().\sA\ssingle\sputVarint()\sdoes\sthe\ssame\sthing\smore\squickly.\s(CVS\s6734) C Enable\scell\soverflow\schecking\sin\ssqlite3BtreeInitPage()\susing\sthe\ncompile-time\soption\sSQLITE_ENABLE_OVERSIZE_CELL_CHECK.\s\sChange\sthe\stests\nso\sthat\sthey\srecognize\sdifferent\serror\smessages\sdepending\son\sthe\ssetting\nof\sthis\smacro.\s(CVS\s6735)
D 2009-06-09T11:34:11 D 2009-06-09T13:42:25
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 8b8fb7823264331210cddf103831816c286ba446 F Makefile.in 8b8fb7823264331210cddf103831816c286ba446
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -106,7 +106,7 @@ F src/auth.c 98db07c2088455797678eb1031f42d4d94d18a71
F src/backup.c ff50af53184a5fd7bdee4d620b5dabef74717c79 F src/backup.c ff50af53184a5fd7bdee4d620b5dabef74717c79
F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119 F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119
F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c
F src/btree.c a5a8e678b06c71547cc6d2b431ada8deed4db82e F src/btree.c a3c7d36de0e97405912d11061d1805e7e969fac5
F src/btree.h f70b694e8c163227369a66863b01fbff9009f323 F src/btree.h f70b694e8c163227369a66863b01fbff9009f323
F src/btreeInt.h df64030d632f8c8ac217ed52e8b6b3eacacb33a5 F src/btreeInt.h df64030d632f8c8ac217ed52e8b6b3eacacb33a5
F src/build.c 20e02fd72249159ff6829009f3029d16d59cdff5 F src/build.c 20e02fd72249159ff6829009f3029d16d59cdff5
@@ -180,7 +180,7 @@ F src/test_async.c 731d23f953ece5bf40ce87810cfb7607218953c5
F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad
F src/test_backup.c 1384a18985a5a2d275c2662e48473bf1542ebd08 F src/test_backup.c 1384a18985a5a2d275c2662e48473bf1542ebd08
F src/test_btree.c d7b8716544611c323860370ee364e897c861f1b0 F src/test_btree.c d7b8716544611c323860370ee364e897c861f1b0
F src/test_config.c a05378089b6773ba36b85727dedf9ec0a16424ce F src/test_config.c f947e2899812144c4c089083ed1554a97cd5f4b0
F src/test_devsym.c 9f4bc2551e267ce7aeda195f3897d0f30c5228f4 F src/test_devsym.c 9f4bc2551e267ce7aeda195f3897d0f30c5228f4
F src/test_func.c b8140bc4ed0d290d5e22972eb2a3bfd40aa798dc F src/test_func.c b8140bc4ed0d290d5e22972eb2a3bfd40aa798dc
F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
@@ -285,7 +285,7 @@ F test/corrupt3.test 263e8bb04e2728df832fddf6973cf54c91db0c32
F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff F test/corrupt4.test acdb01afaedf529004b70e55de1a6f5a05ae7fff
F test/corrupt5.test c23da7bfb20917cc7fdbb13ee25c7cc4e9fffeff F test/corrupt5.test c23da7bfb20917cc7fdbb13ee25c7cc4e9fffeff
F test/corrupt6.test e69b877d478224deab7b66844566258cecacd25e F test/corrupt6.test e69b877d478224deab7b66844566258cecacd25e
F test/corrupt7.test 2aa5790f7e67eddc9bc8d4521b857707326bb61b F test/corrupt7.test 8bfb08842642b1a598a915b52a7f51fbc0289b62
F test/corrupt8.test 9992ef7f67cefc576b92373f6bf5ab8775280f51 F test/corrupt8.test 9992ef7f67cefc576b92373f6bf5ab8775280f51
F test/corrupt9.test 4aa1cb1ef091cb0e13e89a819c72911631b5176a F test/corrupt9.test 4aa1cb1ef091cb0e13e89a819c72911631b5176a
F test/corruptA.test 99e95620b980161cb3e79f06a884a4bb8ae265ff F test/corruptA.test 99e95620b980161cb3e79f06a884a4bb8ae265ff
@@ -733,7 +733,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
P 49f544ebae8dc3cf7cf6189536c56ebb7d258a86 P 2e5d42aeb40c3c6eea373a9ae3fbdf4e8087cd58
R 1f3d12c8cfd8481e0f0a6480315e417f R d62552c29f49213fae384fb6619feacc
U danielk1977 U drh
Z 38c7ee33165ee3f31623c1541ad1c16a Z 5d776a071c01e71a57d59767f05a68ee

View File

@@ -1 +1 @@
2e5d42aeb40c3c6eea373a9ae3fbdf4e8087cd58 56bff6eb2fc5f0afbd96afc986671ec744bd40e1

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give. ** 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. ** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information. ** See the header comment on "btreeInt.h" for additional information.
@@ -1153,7 +1153,7 @@ int sqlite3BtreeInitPage(MemPage *pPage){
** past the end of a page boundary and causes SQLITE_CORRUPT to be ** past the end of a page boundary and causes SQLITE_CORRUPT to be
** returned if it does. ** returned if it does.
*/ */
#if defined(SQLITE_OVERREAD_CHECK) #if defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK)
{ {
int iCellFirst; /* First allowable cell index */ int iCellFirst; /* First allowable cell index */
int iCellLast; /* Last possible cell index */ int iCellLast; /* Last possible cell index */

View File

@@ -16,7 +16,7 @@
** The focus of this file is providing the TCL testing layer ** The focus of this file is providing the TCL testing layer
** access to compile-time constants. ** 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 "sqliteLimit.h"
@@ -177,6 +177,16 @@ static void set_options(Tcl_Interp *interp){
Tcl_SetVar2(interp, "sqlite_options", "columnmetadata", "0", TCL_GLOBAL_ONLY); Tcl_SetVar2(interp, "sqlite_options", "columnmetadata", "0", TCL_GLOBAL_ONLY);
#endif #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 #ifdef SQLITE_OMIT_COMPLETE
Tcl_SetVar2(interp, "sqlite_options", "complete", "0", TCL_GLOBAL_ONLY); Tcl_SetVar2(interp, "sqlite_options", "complete", "0", TCL_GLOBAL_ONLY);
#else #else

View File

@@ -14,7 +14,7 @@
# segfault if it sees a corrupt database file. It specifically focuses # segfault if it sees a corrupt database file. It specifically focuses
# on corrupt cell offsets in a btree page. # 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] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@@ -57,6 +57,10 @@ integrity_check corrupt7-1.4
# Deliberately corrupt some of the cell offsets in the btree page # Deliberately corrupt some of the cell offsets in the btree page
# on page 2 of the database. # on page 2 of the database.
# #
# 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 { do_test corrupt7-2.1 {
db close db close
hexio_write test.db 1062 FF hexio_write test.db 1062 FF
@@ -71,6 +75,22 @@ do_test corrupt7-2.2 {
db eval {PRAGMA integrity_check(1)} db eval {PRAGMA integrity_check(1)}
} {{*** in database main *** } {{*** in database main ***
Page 2: sqlite3BtreeInitPage() returns error code 11}} 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 # The code path that was causing the buffer overrun that this test
# case was checking for was removed. # case was checking for was removed.