mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
More extensive use of SQLITE_CORRUPT_PGNO.
FossilOrigin-Name: 3838332cffb87f77a7c6b357066a59b9dc4f65ef4b3496767ad7ad7c14a77be2
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
||||
C Fix\stypo\sin\svdbe.c\scomment.\sNo\schanges\sto\scode.
|
||||
D 2024-02-02T11:37:03.045
|
||||
C More\sextensive\suse\sof\sSQLITE_CORRUPT_PGNO.
|
||||
D 2024-02-02T18:42:09.735
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@@ -677,7 +677,7 @@ F src/auth.c 19b7ccacae3dfba23fc6f1d0af68134fa216e9040e53b0681b4715445ea030b4
|
||||
F src/backup.c 5c97e8023aab1ce14a42387eb3ae00ba5a0644569e3476f38661fa6f824c3523
|
||||
F src/bitvec.c 9eac5f42c11914d5ef00a75605bb205e934f435c579687f985f1f8b0995c8645
|
||||
F src/btmutex.c 79a43670447eacc651519a429f6ece9fd638563cf95b469d6891185ddae2b522
|
||||
F src/btree.c 186359bd695150d22b9f385ffb487b9a029ecea158658eed3a0268ee63ecbf9c
|
||||
F src/btree.c bf659f4b1622c120ec6a863ba96c63f1861595ca21124950d977cec1477dd922
|
||||
F src/btree.h 03e3356f5208bcab8eed4e094240fdac4a7f9f5ddf5e91045ce589f67d47c240
|
||||
F src/btreeInt.h 3e2589726c4f105e653461814f65857465da68be1fac688de340c43b873f4062
|
||||
F src/build.c 05c9eb387638982092988d2ef4c00a91b0c29baa1b85923f082ce0cf2903ea7e
|
||||
@@ -2161,8 +2161,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P d18d9a05c2d6f290d7b16eafced0cde4eb8dd3f869778a49103812d35a0cee65
|
||||
R aba3b7802d437f5dcd3a746bf90a6079
|
||||
U dan
|
||||
Z 006ae05388cb62c50458a12f4ef45e94
|
||||
P 62010ba488f65aec3c6bd17b05f64c5b3e885dee4221e6016c4eb1053e19284d
|
||||
R ce828c7f8969aa9dd36f079e0d3d1a31
|
||||
U drh
|
||||
Z a60787a93d78c5cb2066cabdbdc63c36
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
@@ -1 +1 @@
|
||||
62010ba488f65aec3c6bd17b05f64c5b3e885dee4221e6016c4eb1053e19284d
|
||||
3838332cffb87f77a7c6b357066a59b9dc4f65ef4b3496767ad7ad7c14a77be2
|
46
src/btree.c
46
src/btree.c
@@ -8310,7 +8310,7 @@ static int balance_nonroot(
|
||||
** table-interior, index-leaf, or index-interior).
|
||||
*/
|
||||
if( pOld->aData[0]!=apOld[0]->aData[0] ){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
rc = SQLITE_CORRUPT_PAGE(pOld);
|
||||
goto balance_cleanup;
|
||||
}
|
||||
|
||||
@@ -8334,7 +8334,7 @@ static int balance_nonroot(
|
||||
memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*(limit+pOld->nOverflow));
|
||||
if( pOld->nOverflow>0 ){
|
||||
if( NEVER(limit<pOld->aiOvfl[0]) ){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
rc = SQLITE_CORRUPT_PAGE(pOld);
|
||||
goto balance_cleanup;
|
||||
}
|
||||
limit = pOld->aiOvfl[0];
|
||||
@@ -8977,7 +8977,7 @@ static int anotherValidCursor(BtCursor *pCur){
|
||||
&& pOther->eState==CURSOR_VALID
|
||||
&& pOther->pPage==pCur->pPage
|
||||
){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pCur->pPage);
|
||||
}
|
||||
}
|
||||
return SQLITE_OK;
|
||||
@@ -9037,7 +9037,7 @@ static int balance(BtCursor *pCur){
|
||||
/* The page being written is not a root page, and there is currently
|
||||
** more than one reference to it. This only happens if the page is one
|
||||
** of its own ancestor pages. Corruption. */
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
rc = SQLITE_CORRUPT_PAGE(pPage);
|
||||
}else{
|
||||
MemPage * const pParent = pCur->apPage[iPage-1];
|
||||
int const iIdx = pCur->aiIdx[iPage-1];
|
||||
@@ -9201,7 +9201,7 @@ static SQLITE_NOINLINE int btreeOverwriteOverflowCell(
|
||||
rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
|
||||
if( rc ) return rc;
|
||||
if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 || pPage->isInit ){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
rc = SQLITE_CORRUPT_PAGE(pPage);
|
||||
}else{
|
||||
if( iOffset+ovflPageSize<(u32)nTotal ){
|
||||
ovflPgno = get4byte(pPage->aData);
|
||||
@@ -9229,7 +9229,7 @@ static int btreeOverwriteCell(BtCursor *pCur, const BtreePayload *pX){
|
||||
if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd
|
||||
|| pCur->info.pPayload < pPage->aData + pPage->cellOffset
|
||||
){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pPage);
|
||||
}
|
||||
if( pCur->info.nLocal==nTotal ){
|
||||
/* The entire cell is local */
|
||||
@@ -9310,7 +9310,7 @@ int sqlite3BtreeInsert(
|
||||
** Which can only happen if the SQLITE_NoSchemaError flag was set when
|
||||
** the schema was loaded. This cannot be asserted though, as a user might
|
||||
** set the flag, load the schema, and then unset the flag. */
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PGNO(pCur->pgnoRoot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9433,7 +9433,7 @@ int sqlite3BtreeInsert(
|
||||
if( pPage->nFree<0 ){
|
||||
if( NEVER(pCur->eState>CURSOR_INVALID) ){
|
||||
/* ^^^^^--- due to the moveToRoot() call above */
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
rc = SQLITE_CORRUPT_PAGE(pPage);
|
||||
}else{
|
||||
rc = btreeComputeFreeSpace(pPage);
|
||||
}
|
||||
@@ -9472,7 +9472,7 @@ int sqlite3BtreeInsert(
|
||||
CellInfo info;
|
||||
assert( idx>=0 );
|
||||
if( idx>=pPage->nCell ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pPage);
|
||||
}
|
||||
rc = sqlite3PagerWrite(pPage->pDbPage);
|
||||
if( rc ){
|
||||
@@ -9499,10 +9499,10 @@ int sqlite3BtreeInsert(
|
||||
** necessary to add the PTRMAP_OVERFLOW1 pointer-map entry. */
|
||||
assert( rc==SQLITE_OK ); /* clearCell never fails when nLocal==nPayload */
|
||||
if( oldCell < pPage->aData+pPage->hdrOffset+10 ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pPage);
|
||||
}
|
||||
if( oldCell+szNew > pPage->aDataEnd ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pPage);
|
||||
}
|
||||
memcpy(oldCell, newCell, szNew);
|
||||
return SQLITE_OK;
|
||||
@@ -9604,7 +9604,7 @@ int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64 iKey){
|
||||
nIn = pSrc->info.nLocal;
|
||||
aIn = pSrc->info.pPayload;
|
||||
if( aIn+nIn>pSrc->pPage->aDataEnd ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pSrc->pPage);
|
||||
}
|
||||
nRem = pSrc->info.nPayload;
|
||||
if( nIn==nRem && nIn<pDest->pPage->maxLocal ){
|
||||
@@ -9629,7 +9629,7 @@ int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64 iKey){
|
||||
|
||||
if( nRem>nIn ){
|
||||
if( aIn+nIn+4>pSrc->pPage->aDataEnd ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pSrc->pPage);
|
||||
}
|
||||
ovflIn = get4byte(&pSrc->info.pPayload[nIn]);
|
||||
}
|
||||
@@ -9725,7 +9725,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
|
||||
assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID );
|
||||
if( rc || pCur->eState!=CURSOR_VALID ) return rc;
|
||||
}else{
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PGNO(pCur->pgnoRoot);
|
||||
}
|
||||
}
|
||||
assert( pCur->eState==CURSOR_VALID );
|
||||
@@ -9734,14 +9734,14 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
|
||||
iCellIdx = pCur->ix;
|
||||
pPage = pCur->pPage;
|
||||
if( pPage->nCell<=iCellIdx ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pPage);
|
||||
}
|
||||
pCell = findCell(pPage, iCellIdx);
|
||||
if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pPage);
|
||||
}
|
||||
if( pCell<&pPage->aCellIdx[pPage->nCell] ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PAGE(pPage);
|
||||
}
|
||||
|
||||
/* If the BTREE_SAVEPOSITION bit is on, then the cursor position must
|
||||
@@ -9832,7 +9832,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
|
||||
n = pCur->pPage->pgno;
|
||||
}
|
||||
pCell = findCell(pLeaf, pLeaf->nCell-1);
|
||||
if( pCell<&pLeaf->aData[4] ) return SQLITE_CORRUPT_BKPT;
|
||||
if( pCell<&pLeaf->aData[4] ) return SQLITE_CORRUPT_PAGE(pLeaf);
|
||||
nCell = pLeaf->xCellSize(pLeaf, pCell);
|
||||
assert( MX_CELL_SIZE(pBt) >= nCell );
|
||||
pTmp = pBt->pTmpSpace;
|
||||
@@ -9948,7 +9948,7 @@ static int btreeCreateTable(Btree *p, Pgno *piTable, int createTabFlags){
|
||||
*/
|
||||
sqlite3BtreeGetMeta(p, BTREE_LARGEST_ROOT_PAGE, &pgnoRoot);
|
||||
if( pgnoRoot>btreePagecount(pBt) ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PGNO(pgnoRoot);
|
||||
}
|
||||
pgnoRoot++;
|
||||
|
||||
@@ -9996,7 +9996,7 @@ static int btreeCreateTable(Btree *p, Pgno *piTable, int createTabFlags){
|
||||
}
|
||||
rc = ptrmapGet(pBt, pgnoRoot, &eType, &iPtrPage);
|
||||
if( eType==PTRMAP_ROOTPAGE || eType==PTRMAP_FREEPAGE ){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
rc = SQLITE_CORRUPT_PGNO(pgnoRoot);
|
||||
}
|
||||
if( rc!=SQLITE_OK ){
|
||||
releasePage(pRoot);
|
||||
@@ -10086,14 +10086,14 @@ static int clearDatabasePage(
|
||||
|
||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||
if( pgno>btreePagecount(pBt) ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PGNO(pgno);
|
||||
}
|
||||
rc = getAndInitPage(pBt, pgno, &pPage, 0);
|
||||
if( rc ) return rc;
|
||||
if( (pBt->openFlags & BTREE_SINGLE)==0
|
||||
&& sqlite3PagerPageRefcount(pPage->pDbPage) != (1 + (pgno==1))
|
||||
){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
rc = SQLITE_CORRUPT_PAGE(pPage);
|
||||
goto cleardatabasepage_out;
|
||||
}
|
||||
hdr = pPage->hdrOffset;
|
||||
@@ -10197,7 +10197,7 @@ static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){
|
||||
assert( p->inTrans==TRANS_WRITE );
|
||||
assert( iTable>=2 );
|
||||
if( iTable>btreePagecount(pBt) ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
return SQLITE_CORRUPT_PGNO(iTable);
|
||||
}
|
||||
|
||||
rc = sqlite3BtreeClearTable(p, iTable, 0);
|
||||
|
Reference in New Issue
Block a user