Skip to content

Commit

Permalink
Detect an attempt to drop a btree that is not within the bounds of the
Browse files Browse the repository at this point in the history
database file and abort early with an SQLITE_CORRUPT error, to avoid
problems later on in the process.
  • Loading branch information
D. Richard Hipp committed Mar 8, 2019
1 parent c6b4d8d commit d8ad99e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -9268,6 +9268,9 @@ static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){
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;
Expand Down

0 comments on commit d8ad99e

Please sign in to comment.