1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Return an SQLITE_CORRUPT error if the final expected size of the database when checkpointing is not reasonable - where reasonable is defined (basically) as the sum of the sizes of the database and wal files.

FossilOrigin-Name: e2799563c8a97f617c6d932719b312e3d5bff051a9a397492df8d88e8bb4260a
This commit is contained in:
dan
2020-08-07 16:28:02 +00:00
parent b19493434f
commit 88819d5870
4 changed files with 44 additions and 10 deletions

View File

@@ -2011,8 +2011,14 @@ static int walCheckpoint(
if( rc==SQLITE_OK && nSize<nReq ){
sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
}
}
/* If the size of the final database is larger than the current
** database plus the amount of data in the wal file, then there
** must be corruption somewhere. */
if( rc==SQLITE_OK && (nSize+(i64)pWal->hdr.mxFrame*szPage)<nReq ){
rc = SQLITE_CORRUPT_BKPT;
}
}
/* Iterate through the contents of the WAL, copying data to the db file */
while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){