1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Fix a case where a checkpoint operation could write to an invalid part of a memory mapped region.

FossilOrigin-Name: 8dbe89d05ce91428c69003f0da79d883fa23e2b5
This commit is contained in:
dan
2013-03-23 14:20:42 +00:00
parent 2753388e8a
commit 9d56c6df9a
5 changed files with 71 additions and 25 deletions

View File

@@ -4232,7 +4232,7 @@ static int syncJournal(Pager *pPager, int newHdr){
*/
int sqlite3PagerSetFilesize(Pager *pPager, i64 szReq){
int rc;
sqlite3_int64 sz;
i64 sz; /* Size of file on disk in bytes */
assert( pPager->eState==PAGER_OPEN );
assert( pPager->nMmapOut==0 );
@@ -4244,13 +4244,13 @@ int sqlite3PagerSetFilesize(Pager *pPager, i64 szReq){
}
}
if( rc==SQLITE_OK
&& pPager->nMapLimit>0
&& pPager->nMapValid<szReq
&& pPager->nMapValid<pPager->nMapLimit
){
pPager->dbFileSize = (szReq / pPager->pageSize);
rc = pagerMap(pPager, 1);
if( rc==SQLITE_OK ){
i64 szMap = (szReq > pPager->nMapLimit) ? pPager->nMapLimit : szReq;
if( pPager->nMapValid!=pPager->nMap || szMap!=pPager->nMap ){
pPager->dbFileSize = (szReq / pPager->pageSize);
rc = pagerMap(pPager, 1);
}
}
return rc;