@@ -1164,7 +1164,7 @@ extern "C" {
11641164*/
11651165#define SQLITE_VERSION "3.33.0"
11661166#define SQLITE_VERSION_NUMBER 3033000
1167- #define SQLITE_SOURCE_ID "2020-07-30 17:37:49 96e3dba2ed3ab0c5b2ecf65a3408633e0767c884d48c270e9ef10ab9fa3ec051 "
1167+ #define SQLITE_SOURCE_ID "2020-08-07 19:52:01 fdc5fb902d7f2d10f73e64fe30c67153b59b26c5d707fc9c354e90967dbcc214 "
11681168
11691169/*
11701170** CAPI3REF: Run-Time Library Version Numbers
@@ -60679,7 +60679,34 @@ static int walIndexRecover(Wal *pWal){
6067960679 pWal->apWiData[iPg] = aShare;
6068060680 nHdr = (iPg==0 ? WALINDEX_HDR_SIZE : 0);
6068160681 nHdr32 = nHdr / sizeof(u32);
60682+ #ifndef SQLITE_SAFER_WALINDEX_RECOVERY
60683+ /* Memcpy() should work fine here, on all reasonable implementations.
60684+ ** Technically, memcpy() might change the destination to some
60685+ ** intermediate value before setting to the final value, and that might
60686+ ** cause a concurrent reader to malfunction. Memcpy() is allowed to
60687+ ** do that, according to the spec, but no memcpy() implementation that
60688+ ** we know of actually does that, which is why we say that memcpy()
60689+ ** is safe for this. Memcpy() is certainly a lot faster.
60690+ */
6068260691 memcpy(&aShare[nHdr32], &aPrivate[nHdr32], WALINDEX_PGSZ-nHdr);
60692+ #else
60693+ /* In the event that some platform is found for which memcpy()
60694+ ** changes the destination to some intermediate value before
60695+ ** setting the final value, this alternative copy routine is
60696+ ** provided.
60697+ */
60698+ {
60699+ int i;
60700+ for(i=nHdr32; i<WALINDEX_PGSZ/sizeof(u32); i++){
60701+ if( aShare[i]!=aPrivate[i] ){
60702+ /* Atomic memory operations are not required here because if
60703+ ** the value needs to be changed, that means it is not being
60704+ ** accessed concurrently. */
60705+ aShare[i] = aPrivate[i];
60706+ }
60707+ }
60708+ }
60709+ #endif
6068360710 if( iFrame<=iLast ) break;
6068460711 }
6068560712
@@ -61379,10 +61406,17 @@ static int walCheckpoint(
6137961406 sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_START, 0);
6138061407 rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
6138161408 if( rc==SQLITE_OK && nSize<nReq ){
61382- sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
61409+ if( (nSize+(i64)pWal->hdr.mxFrame*szPage)<nReq ){
61410+ /* If the size of the final database is larger than the current
61411+ ** database plus the amount of data in the wal file, then there
61412+ ** must be corruption somewhere. */
61413+ rc = SQLITE_CORRUPT_BKPT;
61414+ }else{
61415+ sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT,&nReq);
61416+ }
6138361417 }
61384- }
6138561418
61419+ }
6138661420
6138761421 /* Iterate through the contents of the WAL, copying data to the db file */
6138861422 while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
@@ -70389,7 +70423,7 @@ static int allocateBtreePage(
7038970423 */
7039070424#ifndef SQLITE_OMIT_AUTOVACUUM
7039170425 if( eMode==BTALLOC_EXACT ){
70392- if( ALWAYS( nearby<=mxPage) ){
70426+ if( nearby<=mxPage ){
7039370427 u8 eType;
7039470428 assert( nearby>0 );
7039570429 assert( pBt->autoVacuum );
@@ -70685,7 +70719,7 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
7068570719 assert( CORRUPT_DB || iPage>1 );
7068670720 assert( !pMemPage || pMemPage->pgno==iPage );
7068770721
70688- if( iPage<2 || NEVER( iPage>pBt->nPage) ){
70722+ if( iPage<2 || iPage>pBt->nPage ){
7068970723 return SQLITE_CORRUPT_BKPT;
7069070724 }
7069170725 if( pMemPage ){
@@ -87558,7 +87592,7 @@ case OP_Compare: {
8755887592#ifdef SQLITE_DEBUG
8755987593 if( aPermute ){
8756087594 int k, mx = 0;
87561- for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k];
87595+ for(k=0; k<n; k++) if( aPermute[k]>(u32) mx ) mx = aPermute[k];
8756287596 assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 );
8756387597 assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 );
8756487598 }else{
@@ -87908,7 +87942,7 @@ case OP_Column: {
8790887942 pDest = &aMem[pOp->p3];
8790987943 memAboutToChange(p, pDest);
8791087944 assert( pC!=0 );
87911- assert( p2<pC->nField );
87945+ assert( p2<(u32) pC->nField );
8791287946 aOffset = pC->aOffset;
8791387947 assert( pC->eCurType!=CURTYPE_VTAB );
8791487948 assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
@@ -89097,7 +89131,7 @@ case OP_OpenWrite:
8909789131 }
8909889132 if( pOp->p5 & OPFLAG_P2ISREG ){
8909989133 assert( p2>0 );
89100- assert( p2<=(p->nMem+1 - p->nCursor) );
89134+ assert( p2<=(u32)( p->nMem+1 - p->nCursor) );
8910189135 assert( pOp->opcode==OP_OpenWrite );
8910289136 pIn2 = &aMem[p2];
8910389137 assert( memIsValid(pIn2) );
@@ -91530,7 +91564,7 @@ case OP_IntegrityCk: {
9153091564 nRoot = pOp->p2;
9153191565 aRoot = pOp->p4.ai;
9153291566 assert( nRoot>0 );
91533- assert( aRoot[0]==nRoot );
91567+ assert( aRoot[0]==(Pgno) nRoot );
9153491568 assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) );
9153591569 pnErr = &aMem[pOp->p3];
9153691570 assert( (pnErr->flags & MEM_Int)!=0 );
@@ -113189,7 +113223,7 @@ SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3 *db, int iDb, Pgno iFrom, Pgno
113189113223static void destroyRootPage(Parse *pParse, int iTable, int iDb){
113190113224 Vdbe *v = sqlite3GetVdbe(pParse);
113191113225 int r1 = sqlite3GetTempReg(pParse);
113192- if( NEVER( iTable<2) ) return ;
113226+ if( iTable<2 ) sqlite3ErrorMsg(pParse, "corrupt schema") ;
113193113227 sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);
113194113228 sqlite3MayAbort(pParse);
113195113229#ifndef SQLITE_OMIT_AUTOVACUUM
@@ -188081,6 +188115,7 @@ typedef unsigned int u32;
188081188115/* #include <string.h> */
188082188116/* #include <stdio.h> */
188083188117/* #include <assert.h> */
188118+ /* #include <stdlib.h> */
188084188119
188085188120/* The following macro is used to suppress compiler warnings.
188086188121*/
@@ -188418,6 +188453,23 @@ struct RtreeMatchArg {
188418188453# define testcase(X)
188419188454#endif
188420188455
188456+ /*
188457+ ** Make sure that the compiler intrinsics we desire are enabled when
188458+ ** compiling with an appropriate version of MSVC unless prevented by
188459+ ** the SQLITE_DISABLE_INTRINSIC define.
188460+ */
188461+ #if !defined(SQLITE_DISABLE_INTRINSIC)
188462+ # if defined(_MSC_VER) && _MSC_VER>=1400
188463+ # if !defined(_WIN32_WCE)
188464+ /* # include <intrin.h> */
188465+ # pragma intrinsic(_byteswap_ulong)
188466+ # pragma intrinsic(_byteswap_uint64)
188467+ # else
188468+ /* # include <cmnintrin.h> */
188469+ # endif
188470+ # endif
188471+ #endif
188472+
188421188473/*
188422188474** Macros to determine whether the machine is big or little endian,
188423188475** and whether or not that determination is run-time or compile-time.
@@ -225642,7 +225694,7 @@ static void fts5SourceIdFunc(
225642225694){
225643225695 assert( nArg==0 );
225644225696 UNUSED_PARAM2(nArg, apUnused);
225645- sqlite3_result_text(pCtx, "fts5: 2020-07-29 12:23:20 1d69eee8b085d514f442840346f001b4785f8ec64f5ba66943e9577b26e2e29c ", -1, SQLITE_TRANSIENT);
225697+ sqlite3_result_text(pCtx, "fts5: 2020-08-07 19:52:01 fdc5fb902d7f2d10f73e64fe30c67153b59b26c5d707fc9c354e90967dbcc214 ", -1, SQLITE_TRANSIENT);
225646225698}
225647225699
225648225700/*
@@ -230425,9 +230477,9 @@ SQLITE_API int sqlite3_stmt_init(
230425230477#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
230426230478
230427230479/************** End of stmt.c ************************************************/
230428- #if __LINE__!=230428
230480+ #if __LINE__!=230480
230429230481#undef SQLITE_SOURCE_ID
230430- #define SQLITE_SOURCE_ID "2020-07-30 17:37:49 96e3dba2ed3ab0c5b2ecf65a3408633e0767c884d48c270e9ef10ab9fa3ealt2 "
230482+ #define SQLITE_SOURCE_ID "2020-08-07 19:52:01 fdc5fb902d7f2d10f73e64fe30c67153b59b26c5d707fc9c354e90967dbcalt2 "
230431230483#endif
230432230484/* Return the source-id for this library */
230433230485SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
0 commit comments