/ Check-in [3448b39d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Detect database corruption and abort balance_nonroot() before the corruption causes problems. (CVS 6758)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3448b39dcd580880a9326414e7e4952c4fbc313d
User & Date: drh 2009-06-14 12:47:11
Context
2009-06-15
00:04
Update the configuration script for version 3.6.15. (CVS 6759) check-in: 14df65dc user: drh tags: trunk
2009-06-14
12:47
Detect database corruption and abort balance_nonroot() before the corruption causes problems. (CVS 6758) check-in: 3448b39d user: drh tags: trunk
2009-06-12
17:46
Change lemon so that it does not generate yytestcase() macros on destructor cases since destructors are commonly unreachable in a reasonable grammar. For the reduce-rule switch, gather all no-ops into the "default:" case. (CVS 6757) check-in: caebfe82 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12         -** $Id: btree.c,v 1.626 2009/06/10 09:11:06 danielk1977 Exp $
           12  +** $Id: btree.c,v 1.627 2009/06/14 12:47:11 drh Exp $
    13     13   **
    14     14   ** This file implements a external (disk-based) database using BTrees.
    15     15   ** See the header comment on "btreeInt.h" for additional information.
    16     16   ** Including a description of file format and an overview of operation.
    17     17   */
    18     18   #include "btreeInt.h"
    19     19   
................................................................................
  5542   5542       subtotal += szCell[i] + 2;
  5543   5543       if( subtotal > usableSpace ){
  5544   5544         szNew[k] = subtotal - szCell[i];
  5545   5545         cntNew[k] = i;
  5546   5546         if( leafData ){ i--; }
  5547   5547         subtotal = 0;
  5548   5548         k++;
         5549  +      if( k>NB+1 ){ rc = SQLITE_CORRUPT; goto balance_cleanup; }
  5549   5550       }
  5550   5551     }
  5551   5552     szNew[k] = subtotal;
  5552   5553     cntNew[k] = nCell;
  5553   5554     k++;
  5554   5555   
  5555   5556     /*
................................................................................
  5588   5589     ** page is page 1 and we are the only child of that page.
  5589   5590     */
  5590   5591     assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) );
  5591   5592   
  5592   5593     /*
  5593   5594     ** Allocate k new pages.  Reuse old pages where possible.
  5594   5595     */
  5595         -  assert( apOld[0]->pgno>1 );
         5596  +  if( apOld[0]->pgno<=1 ){
         5597  +    rc = SQLITE_CORRUPT;
         5598  +    goto balance_cleanup;
         5599  +  }
  5596   5600     pageFlags = apOld[0]->aData[0];
  5597   5601     for(i=0; i<k; i++){
  5598   5602       MemPage *pNew;
  5599   5603       if( i<nOld ){
  5600   5604         pNew = apNew[i] = apOld[i];
  5601   5605         pgnoNew[i] = pgnoOld[i];
  5602   5606         apOld[i] = 0;