/ Check-in [eae959ed]
Login

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

Overview
Comment:Fix a segfault that can occur when running integrity_check on a corrupt db. (CVS 5606)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:eae959ede1b2b50190c60de9249cf141c3031ce2
User & Date: danielk1977 2008-08-25 11:57:17
Context
2008-08-25
12:08
Two if statements should be asserts. GCC was silently ignoring them, hence the problem did not show up in coverage testing. Ticket #3333. (CVS 5607) check-in: 635933b1 user: drh tags: trunk
11:57
Fix a segfault that can occur when running integrity_check on a corrupt db. (CVS 5606) check-in: eae959ed user: danielk1977 tags: trunk
07:12
If the sector size is greater than the database page size, SQLite journals all pages that lie within a sector before writing to any of them. This change ensure that a journal sync does not occur halfway through journalling the set of pages that belong to a single sector. (CVS 5605) check-in: 16f612d6 user: danielk1977 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.502 2008/08/23 16:17:56 danielk1977 Exp $
           12  +** $Id: btree.c,v 1.503 2008/08/25 11:57:17 danielk1977 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   
................................................................................
  6754   6754     }else{
  6755   6755       memset(hit, 0, usableSize );
  6756   6756       memset(hit, 1, get2byte(&data[hdr+5]));
  6757   6757       nCell = get2byte(&data[hdr+3]);
  6758   6758       cellStart = hdr + 12 - 4*pPage->leaf;
  6759   6759       for(i=0; i<nCell; i++){
  6760   6760         int pc = get2byte(&data[cellStart+i*2]);
  6761         -      u16 size = cellSizePtr(pPage, &data[pc]);
         6761  +      u16 size = 1024;
  6762   6762         int j;
         6763  +      if( pc<=usableSize ){
         6764  +        size = cellSizePtr(pPage, &data[pc]);
         6765  +      }
  6763   6766         if( (pc+size-1)>=usableSize || pc<0 ){
  6764   6767           checkAppendMsg(pCheck, 0, 
  6765   6768               "Corruption detected in cell %d on page %d",i,iPage,0);
  6766   6769         }else{
  6767   6770           for(j=pc+size-1; j>=pc; j--) hit[j]++;
  6768   6771         }
  6769   6772       }