From 8c2bbb620b2edde8a00e8020163a1800eb2c3c9d Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 10 Jul 2009 02:52:20 +0000 Subject: [PATCH] Simplifications to the PRAGMA integrity_check logic in btree.c. (CVS 6873) FossilOrigin-Name: 440c573c7e2a22f9a67a9571883e205fbadb7c11 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 31 +++++++++++++++---------------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index f84695654f..cbf62e1d71 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stwo\sfaulty\sassert()\sstatements\sbtree.\s\s(It\swas\spossible\sfor\sthe\sassertions\nto\sbe\sfalse\sgiven\sa\scorrupt\sdatabase\sfile\sas\sinput.)\s(CVS\s6872) -D 2009-07-09T13:25:32 +C Simplifications\sto\sthe\sPRAGMA\sintegrity_check\slogic\sin\sbtree.c.\s(CVS\s6873) +D 2009-07-10T02:52:21 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -106,7 +106,7 @@ F src/auth.c 802a9439dfa0b8c208b10055cba400e82ef18025 F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3 F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119 F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c -F src/btree.c 0c58f7879b6439d2acd5c37b19c754873ffb9e5e +F src/btree.c 90b5fbf40b9f0294b23ebec71a374cf32e9ca829 F src/btree.h e53a10fd31d16c60a86f03c9467a6f470aa3683b F src/btreeInt.h a568bf057aa249eb06fd31358b4393a5ac88c118 F src/build.c 867028ee9f63f7bc8eb8d4a720bb98cf9b9a12b4 @@ -740,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746 -P 45efb78a8a1e01a0154153b10469bb34d6d129eb -R 312eb19d05ae6f242619e437dda1112d +P 9403f04dfdabdd2ba9adb1a91ca9b400cf4ca6b3 +R f5584a1b216a472f2389b4db4fb67036 U drh -Z a56b6692cd4d8a5d3fbce96abbee444b +Z edc8374917110976eef49eaed71b43e7 diff --git a/manifest.uuid b/manifest.uuid index 5b3a77549a..90e9b7eb6f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9403f04dfdabdd2ba9adb1a91ca9b400cf4ca6b3 \ No newline at end of file +440c573c7e2a22f9a67a9571883e205fbadb7c11 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index fb8038748a..9560703007 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.672 2009/07/09 13:25:32 drh Exp $ +** $Id: btree.c,v 1.673 2009/07/10 02:52:21 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. @@ -7389,7 +7389,7 @@ static int checkTreePage( int pc = get2byte(&data[cellStart+i*2]); u16 size = 1024; int j; - if( pc<=usableSize ){ + if( pc<=usableSize-4 ){ size = cellSizePtr(pPage, &data[pc]); } if( (pc+size-1)>=usableSize || pc<0 ){ @@ -7399,17 +7399,17 @@ static int checkTreePage( for(j=pc+size-1; j>=pc; j--) hit[j]++; } } - for(cnt=0, i=get2byte(&data[hdr+1]); i>0 && i=usableSize || i<0 ){ - checkAppendMsg(pCheck, 0, - "Corruption detected in cell %d on page %d",i,iPage,0); - }else{ - for(j=i+size-1; j>=i; j--) hit[j]++; - } - i = get2byte(&data[i]); + i = get2byte(&data[hdr+1]); + while( i>0 ){ + int size, j; + assert( i<=usableSize-4 ); /* Enforced by btreeInitPage() */ + size = get2byte(&data[i+2]); + assert( i+size<=usableSize ); /* Enforced by btreeInitPage() */ + for(j=i+size-1; j>=i; j--) hit[j]++; + j = get2byte(&data[i]); + assert( j==0 || j>i+size ); /* Enforced by btreeInitPage() */ + assert( j<=usableSize-4 ); /* Enforced by btreeInitPage() */ + i = j; } for(i=cnt=0; i