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

Do the oversize-WAL corruption test before the size hint is issued.

FossilOrigin-Name: fdc5fb902d7f2d10f73e64fe30c67153b59b26c5d707fc9c354e90967dbcc214
This commit is contained in:
drh
2020-08-07 19:52:01 +00:00
parent 26b9540fc2
commit 799443b14f
3 changed files with 16 additions and 15 deletions

View File

@@ -2009,15 +2009,16 @@ static int walCheckpoint(
sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_START, 0);
rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
if( rc==SQLITE_OK && nSize<nReq ){
sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
if( (nSize+(i64)pWal->hdr.mxFrame*szPage)<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. */
rc = SQLITE_CORRUPT_BKPT;
}else{
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 */