mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Store the MemPage structure in memory following, instead of preceding, the page data for cached pages. This reduces the likelihood of a corrupt database page image causing SQLite to read past the end of a buffer.
FossilOrigin-Name: 0ce42e76654d9ba52dac74c940d38b17866016ba
This commit is contained in:
10
src/pcache.c
10
src/pcache.c
@@ -260,15 +260,17 @@ int sqlite3PcacheFetch(
|
||||
|
||||
if( pPage ){
|
||||
if( !pPage->pData ){
|
||||
memset(pPage, 0, sizeof(PgHdr) + pCache->szExtra);
|
||||
pPage->pExtra = (void*)&pPage[1];
|
||||
pPage->pData = (void *)&((char *)pPage)[sizeof(PgHdr) + pCache->szExtra];
|
||||
memset(pPage, 0, sizeof(PgHdr));
|
||||
pPage->pData = (void *)&pPage[1];
|
||||
pPage->pExtra = (void*)&((char *)pPage->pData)[pCache->szPage];
|
||||
memset(pPage->pExtra, 0, pCache->szExtra);
|
||||
pPage->pCache = pCache;
|
||||
pPage->pgno = pgno;
|
||||
}
|
||||
assert( pPage->pCache==pCache );
|
||||
assert( pPage->pgno==pgno );
|
||||
assert( pPage->pExtra==(void *)&pPage[1] );
|
||||
assert( pPage->pData==(void *)&pPage[1] );
|
||||
assert( pPage->pExtra==(void *)&((char *)&pPage[1])[pCache->szPage] );
|
||||
|
||||
if( 0==pPage->nRef ){
|
||||
pCache->nRef++;
|
||||
|
||||
Reference in New Issue
Block a user