1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Fix a problem causing false corruption reports following recovery of a *-wal file that contains one or more transactions and a *-wal2 file that contains a valid header but no valid transactions.

FossilOrigin-Name: f6eafb65a43c650b065abe4a59e329c977cab1856c72dc9162046576d7bbfc8a
This commit is contained in:
dan
2022-06-27 21:42:45 +00:00
parent e81feadb41
commit 86b7bb29da
4 changed files with 65 additions and 10 deletions

View File

@@ -1827,7 +1827,8 @@ static int walIndexRecover(Wal *pWal){
if( isOpen(pWal->apWalFd[1]) ){
/* The case where *-wal2 may follow *-wal */
if( nCkpt2<=0x0F && nCkpt2==nCkpt1+1 ){
if( sqlite3Get4byte((u8*)(&pWal->hdr.aSalt[0]))==hdr.aFrameCksum[0]
if( pWal->hdr.mxFrame
&& sqlite3Get4byte((u8*)(&pWal->hdr.aSalt[0]))==hdr.aFrameCksum[0]
&& sqlite3Get4byte((u8*)(&pWal->hdr.aSalt[1]))==hdr.aFrameCksum[1]
){
walidxSetFile(&pWal->hdr, 1);
@@ -1840,7 +1841,8 @@ static int walIndexRecover(Wal *pWal){
/* When *-wal may follow *-wal2 */
if( (nCkpt2==0x0F && nCkpt1==0) || (nCkpt2<0x0F && nCkpt2==nCkpt1-1) ){
if( sqlite3Get4byte((u8*)(&hdr.aSalt[0]))==pWal->hdr.aFrameCksum[0]
if( hdr.mxFrame
&& sqlite3Get4byte((u8*)(&hdr.aSalt[0]))==pWal->hdr.aFrameCksum[0]
&& sqlite3Get4byte((u8*)(&hdr.aSalt[1]))==pWal->hdr.aFrameCksum[1]
){
SWAP(WalIndexHdr, pWal->hdr, hdr);