From: drh <> Date: Tue, 22 Mar 2022 23:47:25 +0000 (+0000) Subject: Ensure that database corruption does not cause the cursor passed into X-Git-Tag: version-3.38.2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1905379eb138f72cb91d47bf80e35601669f8b07;p=thirdparty%2Fsqlite.git Ensure that database corruption does not cause the cursor passed into sqlite3BtreeDelete() to be invalid. dbsqlfuzz 209bf3de9ee11ae440848ab9bc9c13858f9be2e4. FossilOrigin-Name: 780d00d4ec8c87229a639671a610c4561f2ab2b1729bb9a4386547ac18772dd4 --- diff --git a/manifest b/manifest index 1084c5d88e..a897703089 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Harden\sthe\sxShmLock\smethod\sof\sboth\sthe\sunix\sand\sWindows\sVFSes\sso\sthat\sthey\nare\srobust\sagainst\sbeing\sinvoked\swhen\sthe\sSHM\sfile\sis\snot\sopen. -D 2022-03-22T20:02:53.848 +C Ensure\sthat\sdatabase\scorruption\sdoes\snot\scause\sthe\scursor\spassed\sinto\nsqlite3BtreeDelete()\sto\sbe\sinvalid.\ndbsqlfuzz\s209bf3de9ee11ae440848ab9bc9c13858f9be2e4. +D 2022-03-22T23:47:25.190 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -492,7 +492,7 @@ F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf F src/backup.c a2891172438e385fdbe97c11c9745676bec54f518d4447090af97189fd8e52d7 F src/bitvec.c 7c849aac407230278445cb069bebc5f89bf2ddd87c5ed9459b070a9175707b3d F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6 -F src/btree.c 94e354923813f151ff9e98334ad603aedf7019207b7867317861c4f83565addd +F src/btree.c 1ebe34ee736e05ead62bcf762a71c5779526356b0616dec67f20478d008e2eb4 F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22 F src/btreeInt.h 8be97d3939d626f734ec1b577efa4e6e186da00daf5b3227af199ca1c24cdd71 F src/build.c a0cc68fe8172c0a31b54576f9c6c0fe6f7c82b1b5e1387afdd6a5a13132bc131 @@ -1944,9 +1944,9 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 883fec9c3a410280bd5160acf1e103fa3c5fb6c6a003b2b99567d3b7037bc07e -Q +67d8b434f628d44c4a90ce8ff5ab2e381f500bb42bdbfab9a17d21925a2ec6cd -R 80ff887e870c4a46d8cc400d89965c94 +P 06d4c4d17c49b98701e4b09c19c0cc68e65a0413850fda33b4991fa24fc84fa0 +Q +a85126f96614c53b030c6e6c43ff239eae458048597a10e9a0361fcec8628ecf +R aba1355516868cd709d449bf9dbe81b7 U drh -Z 242bda5e05c3bfda786964ea91f8e8b8 +Z f525e6a4adcf92804064f386dbd84060 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 5ef371b16c..4a99693678 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -06d4c4d17c49b98701e4b09c19c0cc68e65a0413850fda33b4991fa24fc84fa0 \ No newline at end of file +780d00d4ec8c87229a639671a610c4561f2ab2b1729bb9a4386547ac18772dd4 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 8459b9d410..116342390b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -9265,12 +9265,16 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){ assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) ); assert( !hasReadConflicts(p, pCur->pgnoRoot) ); assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 ); - if( pCur->eState==CURSOR_REQUIRESEEK ){ - rc = btreeRestoreCursorPosition(pCur); - assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID ); - if( rc || pCur->eState!=CURSOR_VALID ) return rc; + if( pCur->eState!=CURSOR_VALID ){ + if( pCur->eState>=CURSOR_REQUIRESEEK ){ + rc = btreeRestoreCursorPosition(pCur); + assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID ); + if( rc || pCur->eState!=CURSOR_VALID ) return rc; + }else{ + return SQLITE_CORRUPT_BKPT; + } } - assert( CORRUPT_DB || pCur->eState==CURSOR_VALID ); + assert( pCur->eState==CURSOR_VALID ); iCellDepth = pCur->iPage; iCellIdx = pCur->ix;