SQLite

Check-in [235a9698f5]
Login

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

Overview
Comment:Detect an attempt to drop a btree that is not within the bounds of the database file and abort early with an SQLITE_CORRUPT error, to avoid problems later on in the process.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 235a9698f5e9b3c21dc51c9c5042becfb82fc1762a7519a46b9f9fdafe9b0f13
User & Date: drh 2019-03-08 01:52:30.651
Context
2019-03-08
13:27
Fix another segfault in fts3 that could occur with corrupt records. (check-in: fcc24edde4 user: dan tags: trunk)
01:52
Detect an attempt to drop a btree that is not within the bounds of the database file and abort early with an SQLITE_CORRUPT error, to avoid problems later on in the process. (check-in: 235a9698f5 user: drh tags: trunk)
2019-03-06
14:53
Add the sqlite3_stmt_isexplain() interface. (check-in: ee642d3e27 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
9264
9265
9266
9267
9268
9269
9270



9271
9272
9273
9274
9275
9276
9277
  int rc;
  MemPage *pPage = 0;
  BtShared *pBt = p->pBt;

  assert( sqlite3BtreeHoldsMutex(p) );
  assert( p->inTrans==TRANS_WRITE );
  assert( iTable>=2 );




  rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0);
  if( rc ) return rc;
  rc = sqlite3BtreeClearTable(p, iTable, 0);
  if( rc ){
    releasePage(pPage);
    return rc;







>
>
>







9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
  int rc;
  MemPage *pPage = 0;
  BtShared *pBt = p->pBt;

  assert( sqlite3BtreeHoldsMutex(p) );
  assert( p->inTrans==TRANS_WRITE );
  assert( iTable>=2 );
  if( iTable>btreePagecount(pBt) ){
    return SQLITE_CORRUPT_BKPT;
  }

  rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0);
  if( rc ) return rc;
  rc = sqlite3BtreeClearTable(p, iTable, 0);
  if( rc ){
    releasePage(pPage);
    return rc;