/ Check-in [fb125bd3]
Login

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

Overview
Comment:The defragmentPage() routine detects corruption in the first-free-slot fields at offset 1 in the header and throws an error, rather than asserting.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fb125bd338ab32b33d02fe61b76497b6d4a2a160056d6e759e15c94903e61a41
User & Date: drh 2019-03-30 18:39:13
Context
2019-03-30
19:17
Add a call to sqlite3FaultSim(410) inside of btreeRestoreCursorPosition() to simplify testing of error scenarios. check-in: bb643bac user: drh tags: trunk
18:39
The defragmentPage() routine detects corruption in the first-free-slot fields at offset 1 in the header and throws an error, rather than asserting. check-in: fb125bd3 user: drh tags: trunk
17:30
Add the blobio.c extension module implementing readblob() and writeblob(). Experimental. check-in: e3fde56d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  1428   1428     /* This block handles pages with two or fewer free blocks and nMaxFrag
  1429   1429     ** or fewer fragmented bytes. In this case it is faster to move the
  1430   1430     ** two (or one) blocks of cells using memmove() and add the required
  1431   1431     ** offsets to each pointer in the cell-pointer array than it is to 
  1432   1432     ** reconstruct the entire page.  */
  1433   1433     if( (int)data[hdr+7]<=nMaxFrag ){
  1434   1434       int iFree = get2byte(&data[hdr+1]);
  1435         -
  1436         -    /* If the initial freeblock offset were out of bounds, that would have
  1437         -    ** been detected by btreeComputeFreeSpace() when it was computing the
  1438         -    ** number of free bytes on the page. */
  1439         -    assert( iFree<=usableSize-4 );
         1435  +    if( iFree>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
  1440   1436       if( iFree ){
  1441   1437         int iFree2 = get2byte(&data[iFree]);
  1442   1438         if( iFree2>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
  1443   1439         if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){
  1444   1440           u8 *pEnd = &data[cellOffset + nCell*2];
  1445   1441           u8 *pAddr;
  1446   1442           int sz2 = 0;