From: drh Date: Fri, 30 Dec 2016 13:40:41 +0000 (+0000) Subject: Improved detection of zero page numbers in the page cache. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=97d5173efe8e8b3240febc46b9119e8091503f91;p=thirdparty%2Fsqlite.git Improved detection of zero page numbers in the page cache. FossilOrigin-Name: 5550e815dd943b15c3b08f0526280bba76976199 --- diff --git a/manifest b/manifest index a98844efba..c9737ac295 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sharmless\scompiler\swarning\sin\sfuzzcheck.c -D 2016-12-30T12:10:48.960 +C Improved\sdetection\sof\szero\spage\snumbers\sin\sthe\spage\scache. +D 2016-12-30T13:40:41.684 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -375,12 +375,12 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 30e2c43e4955db990e5b5a81e901f8aa74cc8820 F src/os_win.c cf90abd4e50d9f56d2c20ce8e005aff55d7bd8e9 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 1c7a2b82b290b85b90f9275ae003f688935f70f9 +F src/pager.c 71881289acefc52888c781cc1d3ea659c311a5da F src/pager.h d1e944291030351f362a0a7da9b5c3e34e603e39 F src/parse.y 29153738a7322054359320eb00b5a4cd44389f20 F src/pcache.c 51070ec9b8251bbf9c6ea3d35fd96a458752929e F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490 -F src/pcache1.c e3967219b2a92b9edcb9324a4ba75009090d3953 +F src/pcache1.c 26a72c84d7ed96d85da7910194d01da9777a3335 F src/pragma.c 5a23557e490e7ac5afef097efc4b59dce5b482c2 F src/pragma.h f9b221b2c8949ea941dbee49934299e4ed5af41c F src/prepare.c b1140c3d0cf59bc85ace00ce363153041b424b7a @@ -1540,7 +1540,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 3e25ba6e42fba239795a465b8510386a361ee5be -R cb43d33d19adf32bebd1dfaa0e0b456a +P 2842bc60538369f888c7df8365858c910322277d +R 055be9062a2560beea507ce779b9565f U drh -Z 067d360edde333b631fbf0df03bf7c2e +Z 9a04ffa20091cdf405452df841cb044b diff --git a/manifest.uuid b/manifest.uuid index 6755f6c671..6b1586a252 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2842bc60538369f888c7df8365858c910322277d \ No newline at end of file +5550e815dd943b15c3b08f0526280bba76976199 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 073bf35edb..a6c8078f11 100644 --- a/src/pager.c +++ b/src/pager.c @@ -5376,7 +5376,11 @@ static int getPageNormal( pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3); if( pBase==0 ){ pPg = 0; - rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase); + if( pgno==0 ){ + rc = SQLITE_CORRUPT_BKPT; + }else{ + rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase); + } if( rc!=SQLITE_OK ) goto pager_acquire_err; if( pBase==0 ){ rc = SQLITE_NOMEM_BKPT; @@ -5400,11 +5404,11 @@ static int getPageNormal( /* The pager cache has created a new page. Its content needs to ** be initialized. But first some error checks: ** - ** (1) Minimum page number is 1 - ** (2) The maximum page number is 2^31 - ** (3) Never try to fetch the locking page + ** (1) The maximum page number is 2^31 + ** (2) Never try to fetch the locking page */ - if( pgno==0 || pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){ + assert( pgno>0 ); + if( pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){ rc = SQLITE_CORRUPT_BKPT; goto pager_acquire_err; } diff --git a/src/pcache1.c b/src/pcache1.c index 110d7ec656..3d73212796 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -997,7 +997,7 @@ static PgHdr1 *pcache1FetchNoMutex( }else{ return pPage; } - }else if( createFlag ){ + }else if( createFlag && iKey ){ /* Steps 3, 4, and 5 implemented by this subroutine */ return pcache1FetchStage2(pCache, iKey, createFlag); }else{