better-sqlite3-multiple-ciphers 12.6.2 → 12.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -123,7 +123,7 @@ SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
123
123
  /*** Begin of #include "sqlite3patched.c" ***/
124
124
  /******************************************************************************
125
125
  ** This file is an amalgamation of many separate C source files from SQLite
126
- ** version 3.51.2. By combining all the individual C code files into this
126
+ ** version 3.51.3. By combining all the individual C code files into this
127
127
  ** single large file, the entire code can be compiled as a single translation
128
128
  ** unit. This allows many compilers to do optimizations that would not be
129
129
  ** possible if the files were compiled separately. Performance improvements
@@ -141,7 +141,7 @@ SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
141
141
  ** separate file. This file contains only code for the core SQLite library.
142
142
  **
143
143
  ** The content in this amalgamation comes from Fossil check-in
144
- ** b270f8339eb13b504d0b2ba154ebca966b7d with changes in files:
144
+ ** 737ae4a34738ffa0c3ff7f9bb18df914dd1c with changes in files:
145
145
  **
146
146
  **
147
147
  */
@@ -591,12 +591,12 @@ extern "C" {
591
591
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
592
592
  ** [sqlite_version()] and [sqlite_source_id()].
593
593
  */
594
- #define SQLITE_VERSION "3.51.2"
595
- #define SQLITE_VERSION_NUMBER 3051002
596
- #define SQLITE_SOURCE_ID "2026-01-09 17:27:48 b270f8339eb13b504d0b2ba154ebca966b7dde08e40c3ed7d559749818cb2075"
594
+ #define SQLITE_VERSION "3.51.3"
595
+ #define SQLITE_VERSION_NUMBER 3051003
596
+ #define SQLITE_SOURCE_ID "2026-03-13 10:38:09 737ae4a34738ffa0c3ff7f9bb18df914dd1cad163f28fd6b6e114a344fe6d618"
597
597
  #define SQLITE_SCM_BRANCH "branch-3.51"
598
- #define SQLITE_SCM_TAGS "release version-3.51.2"
599
- #define SQLITE_SCM_DATETIME "2026-01-09T17:27:48.405Z"
598
+ #define SQLITE_SCM_TAGS "release version-3.51.3"
599
+ #define SQLITE_SCM_DATETIME "2026-03-13T10:38:09.694Z"
600
600
 
601
601
  /*
602
602
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -14472,6 +14472,27 @@ SQLITE_PRIVATE int sqlite3mc_builtin_extensions(sqlite3* db);
14472
14472
  #endif
14473
14473
  #define SQLITE_MIN_LENGTH 30 /* Minimum value for the length limit */
14474
14474
 
14475
+ /*
14476
+ ** Maximum size of any single memory allocation.
14477
+ **
14478
+ ** This is not a limit on the total amount of memory used. This is
14479
+ ** a limit on the size parameter to sqlite3_malloc() and sqlite3_realloc().
14480
+ **
14481
+ ** The upper bound is slightly less than 2GiB: 0x7ffffeff == 2,147,483,391
14482
+ ** This provides a 256-byte safety margin for defense against 32-bit
14483
+ ** signed integer overflow bugs when computing memory allocation sizes.
14484
+ ** Paranoid applications might want to reduce the maximum allocation size
14485
+ ** further for an even larger safety margin. 0x3fffffff or 0x0fffffff
14486
+ ** or even smaller would be reasonable upper bounds on the size of a memory
14487
+ ** allocations for most applications.
14488
+ */
14489
+ #ifndef SQLITE_MAX_ALLOCATION_SIZE
14490
+ # define SQLITE_MAX_ALLOCATION_SIZE 2147483391
14491
+ #endif
14492
+ #if SQLITE_MAX_ALLOCATION_SIZE>2147483391
14493
+ # error Maximum size for SQLITE_MAX_ALLOCATION_SIZE is 2147483391
14494
+ #endif
14495
+
14475
14496
  /*
14476
14497
  ** This is the maximum number of
14477
14498
  **
@@ -21802,6 +21823,7 @@ SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList
21802
21823
  Expr*,ExprList*,u32,Expr*);
21803
21824
  SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
21804
21825
  SQLITE_PRIVATE void sqlite3SelectDeleteGeneric(sqlite3*,void*);
21826
+ SQLITE_PRIVATE void sqlite3SelectCheckOnClauses(Parse *pParse, Select *pSelect);
21805
21827
  SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*);
21806
21828
  SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, Trigger*);
21807
21829
  SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
@@ -31454,27 +31476,6 @@ static void mallocWithAlarm(int n, void **pp){
31454
31476
  *pp = p;
31455
31477
  }
31456
31478
 
31457
- /*
31458
- ** Maximum size of any single memory allocation.
31459
- **
31460
- ** This is not a limit on the total amount of memory used. This is
31461
- ** a limit on the size parameter to sqlite3_malloc() and sqlite3_realloc().
31462
- **
31463
- ** The upper bound is slightly less than 2GiB: 0x7ffffeff == 2,147,483,391
31464
- ** This provides a 256-byte safety margin for defense against 32-bit
31465
- ** signed integer overflow bugs when computing memory allocation sizes.
31466
- ** Paranoid applications might want to reduce the maximum allocation size
31467
- ** further for an even larger safety margin. 0x3fffffff or 0x0fffffff
31468
- ** or even smaller would be reasonable upper bounds on the size of a memory
31469
- ** allocations for most applications.
31470
- */
31471
- #ifndef SQLITE_MAX_ALLOCATION_SIZE
31472
- # define SQLITE_MAX_ALLOCATION_SIZE 2147483391
31473
- #endif
31474
- #if SQLITE_MAX_ALLOCATION_SIZE>2147483391
31475
- # error Maximum size for SQLITE_MAX_ALLOCATION_SIZE is 2147483391
31476
- #endif
31477
-
31478
31479
  /*
31479
31480
  ** Allocate memory. This routine is like sqlite3_malloc() except that it
31480
31481
  ** assumes the memory subsystem has already been initialized.
@@ -31698,8 +31699,7 @@ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
31698
31699
  sqlite3_free(pOld); /* IMP: R-26507-47431 */
31699
31700
  return 0;
31700
31701
  }
31701
- if( nBytes>=0x7fffff00 ){
31702
- /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */
31702
+ if( nBytes>SQLITE_MAX_ALLOCATION_SIZE ){
31703
31703
  return 0;
31704
31704
  }
31705
31705
  nOld = sqlite3MallocSize(pOld);
@@ -69159,68 +69159,82 @@ static int walCheckpoint(
69159
69159
  && (rc = walBusyLock(pWal,xBusy,pBusyArg,WAL_READ_LOCK(0),1))==SQLITE_OK
69160
69160
  ){
69161
69161
  u32 nBackfill = pInfo->nBackfill;
69162
- pInfo->nBackfillAttempted = mxSafeFrame; SEH_INJECT_FAULT;
69163
-
69164
- /* Sync the WAL to disk */
69165
- rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));
69166
-
69167
- /* If the database may grow as a result of this checkpoint, hint
69168
- ** about the eventual size of the db file to the VFS layer.
69169
- */
69170
- if( rc==SQLITE_OK ){
69171
- i64 nReq = ((i64)mxPage * szPage);
69172
- i64 nSize; /* Current size of database file */
69173
- sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_START, 0);
69174
- rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
69175
- if( rc==SQLITE_OK && nSize<nReq ){
69176
- if( (nSize+65536+(i64)pWal->hdr.mxFrame*szPage)<nReq ){
69177
- /* If the size of the final database is larger than the current
69178
- ** database plus the amount of data in the wal file, plus the
69179
- ** maximum size of the pending-byte page (65536 bytes), then
69180
- ** must be corruption somewhere. */
69181
- rc = SQLITE_CORRUPT_BKPT;
69182
- }else{
69183
- sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT,&nReq);
69162
+ WalIndexHdr *pLive = (WalIndexHdr*)walIndexHdr(pWal);
69163
+
69164
+ /* Now that read-lock slot 0 is locked, check that the wal has not been
69165
+ ** wrapped since the header was read for this checkpoint. If it was, then
69166
+ ** there was no work to do anyway. In this case the
69167
+ ** (pInfo->nBackfill<pWal->hdr.mxFrame) test above only passed because
69168
+ ** pInfo->nBackfill had already been set to 0 by the writer that wrapped
69169
+ ** the wal file. It would also be dangerous to proceed, as there may be
69170
+ ** fewer than pWal->hdr.mxFrame valid frames in the wal file. */
69171
+ int bChg = memcmp(pLive->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt));
69172
+ if( 0==bChg ){
69173
+ pInfo->nBackfillAttempted = mxSafeFrame; SEH_INJECT_FAULT;
69174
+
69175
+ /* Sync the WAL to disk */
69176
+ rc = sqlite3OsSync(pWal->pWalFd, CKPT_SYNC_FLAGS(sync_flags));
69177
+
69178
+ /* If the database may grow as a result of this checkpoint, hint
69179
+ ** about the eventual size of the db file to the VFS layer.
69180
+ */
69181
+ if( rc==SQLITE_OK ){
69182
+ i64 nReq = ((i64)mxPage * szPage);
69183
+ i64 nSize; /* Current size of database file */
69184
+ sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_START, 0);
69185
+ rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
69186
+ if( rc==SQLITE_OK && nSize<nReq ){
69187
+ if( (nSize+65536+(i64)pWal->hdr.mxFrame*szPage)<nReq ){
69188
+ /* If the size of the final database is larger than the current
69189
+ ** database plus the amount of data in the wal file, plus the
69190
+ ** maximum size of the pending-byte page (65536 bytes), then
69191
+ ** must be corruption somewhere. */
69192
+ rc = SQLITE_CORRUPT_BKPT;
69193
+ }else{
69194
+ sqlite3OsFileControlHint(
69195
+ pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
69196
+ }
69184
69197
  }
69185
- }
69186
69198
 
69187
- }
69188
-
69189
- /* Iterate through the contents of the WAL, copying data to the db file */
69190
- while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
69191
- i64 iOffset;
69192
- assert( walFramePgno(pWal, iFrame)==iDbpage );
69193
- SEH_INJECT_FAULT;
69194
- if( AtomicLoad(&db->u1.isInterrupted) ){
69195
- rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;
69196
- break;
69197
69199
  }
69198
- if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){
69199
- continue;
69200
- }
69201
- iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
69202
- /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
69203
- rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
69204
- if( rc!=SQLITE_OK ) break;
69205
- iOffset = (iDbpage-1)*(i64)szPage;
69206
- testcase( IS_BIG_INT(iOffset) );
69207
- rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
69208
- if( rc!=SQLITE_OK ) break;
69209
- }
69210
- sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_DONE, 0);
69211
69200
 
69212
- /* If work was actually accomplished... */
69213
- if( rc==SQLITE_OK ){
69214
- if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
69215
- i64 szDb = pWal->hdr.nPage*(i64)szPage;
69216
- testcase( IS_BIG_INT(szDb) );
69217
- rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
69218
- if( rc==SQLITE_OK ){
69219
- rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));
69201
+ /* Iterate through the contents of the WAL, copying data to the
69202
+ ** db file */
69203
+ while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
69204
+ i64 iOffset;
69205
+ assert( walFramePgno(pWal, iFrame)==iDbpage );
69206
+ SEH_INJECT_FAULT;
69207
+ if( AtomicLoad(&db->u1.isInterrupted) ){
69208
+ rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_INTERRUPT;
69209
+ break;
69220
69210
  }
69211
+ if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){
69212
+ continue;
69213
+ }
69214
+ iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
69215
+ /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
69216
+ rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
69217
+ if( rc!=SQLITE_OK ) break;
69218
+ iOffset = (iDbpage-1)*(i64)szPage;
69219
+ testcase( IS_BIG_INT(iOffset) );
69220
+ rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
69221
+ if( rc!=SQLITE_OK ) break;
69221
69222
  }
69223
+ sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_CKPT_DONE, 0);
69224
+
69225
+ /* If work was actually accomplished... */
69222
69226
  if( rc==SQLITE_OK ){
69223
- AtomicStore(&pInfo->nBackfill, mxSafeFrame); SEH_INJECT_FAULT;
69227
+ if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
69228
+ i64 szDb = pWal->hdr.nPage*(i64)szPage;
69229
+ testcase( IS_BIG_INT(szDb) );
69230
+ rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
69231
+ if( rc==SQLITE_OK ){
69232
+ rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));
69233
+ }
69234
+ }
69235
+ if( rc==SQLITE_OK ){
69236
+ AtomicStore(&pInfo->nBackfill, mxSafeFrame); SEH_INJECT_FAULT;
69237
+ }
69224
69238
  }
69225
69239
  }
69226
69240
 
@@ -71270,6 +71284,7 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint(
71270
71284
 
71271
71285
  /* Copy data from the log to the database file. */
71272
71286
  if( rc==SQLITE_OK ){
71287
+ sqlite3FaultSim(660);
71273
71288
  if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){
71274
71289
  rc = SQLITE_CORRUPT_BKPT;
71275
71290
  }else if( eMode2!=SQLITE_CHECKPOINT_NOOP ){
@@ -77705,7 +77720,7 @@ static int accessPayload(
77705
77720
 
77706
77721
  getCellInfo(pCur);
77707
77722
  aPayload = pCur->info.pPayload;
77708
- assert( offset+amt <= pCur->info.nPayload );
77723
+ assert( (u64)offset+(u64)amt <= (u64)pCur->info.nPayload );
77709
77724
 
77710
77725
  assert( aPayload > pPage->aData );
77711
77726
  if( (uptr)(aPayload - pPage->aData) > (pBt->usableSize - pCur->info.nLocal) ){
@@ -86185,7 +86200,12 @@ SQLITE_PRIVATE int sqlite3VdbeMemFromBtree(
86185
86200
  ){
86186
86201
  int rc;
86187
86202
  pMem->flags = MEM_Null;
86188
- if( sqlite3BtreeMaxRecordSize(pCur)<offset+amt ){
86203
+ testcase( amt==SQLITE_MAX_ALLOCATION_SIZE-1 );
86204
+ testcase( amt==SQLITE_MAX_ALLOCATION_SIZE );
86205
+ if( amt>=SQLITE_MAX_ALLOCATION_SIZE ){
86206
+ return SQLITE_NOMEM_BKPT;
86207
+ }
86208
+ if( (u64)amt + (u64)offset > (u64)sqlite3BtreeMaxRecordSize(pCur) ){
86189
86209
  return SQLITE_CORRUPT_BKPT;
86190
86210
  }
86191
86211
  if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){
@@ -93598,7 +93618,7 @@ static int valueFromValueList(
93598
93618
  Mem sMem; /* Raw content of current row */
93599
93619
  memset(&sMem, 0, sizeof(sMem));
93600
93620
  sz = sqlite3BtreePayloadSize(pRhs->pCsr);
93601
- rc = sqlite3VdbeMemFromBtreeZeroOffset(pRhs->pCsr,(int)sz,&sMem);
93621
+ rc = sqlite3VdbeMemFromBtreeZeroOffset(pRhs->pCsr,sz,&sMem);
93602
93622
  if( rc==SQLITE_OK ){
93603
93623
  u8 *zBuf = (u8*)sMem.z;
93604
93624
  u32 iSerial;
@@ -111340,6 +111360,14 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
111340
111360
  return WRC_Abort;
111341
111361
  }
111342
111362
 
111363
+ /* If the SELECT statement contains ON clauses that were moved into
111364
+ ** the WHERE clause, go through and verify that none of the terms
111365
+ ** in the ON clauses reference tables to the right of the ON clause. */
111366
+ if( (p->selFlags & SF_OnToWhere) ){
111367
+ sqlite3SelectCheckOnClauses(pParse, p);
111368
+ if( pParse->nErr ) return WRC_Abort;
111369
+ }
111370
+
111343
111371
  /* Advance to the next term of the compound
111344
111372
  */
111345
111373
  p = p->pPrior;
@@ -154516,7 +154544,7 @@ static int selectCheckOnClausesSelect(Walker *pWalker, Select *pSelect){
154516
154544
  ** Check all ON clauses in pSelect to verify that they do not reference
154517
154545
  ** columns to the right.
154518
154546
  */
154519
- static void selectCheckOnClauses(Parse *pParse, Select *pSelect){
154547
+ SQLITE_PRIVATE void sqlite3SelectCheckOnClauses(Parse *pParse, Select *pSelect){
154520
154548
  Walker w;
154521
154549
  CheckOnCtx sCtx;
154522
154550
  assert( pSelect->selFlags & SF_OnToWhere );
@@ -154659,18 +154687,6 @@ SQLITE_PRIVATE int sqlite3Select(
154659
154687
  }
154660
154688
  #endif
154661
154689
 
154662
- /* If the SELECT statement contains ON clauses that were moved into
154663
- ** the WHERE clause, go through and verify that none of the terms
154664
- ** in the ON clauses reference tables to the right of the ON clause.
154665
- ** Do this now, after name resolution, but before query flattening
154666
- */
154667
- if( p->selFlags & SF_OnToWhere ){
154668
- selectCheckOnClauses(pParse, p);
154669
- if( pParse->nErr ){
154670
- goto select_end;
154671
- }
154672
- }
154673
-
154674
154690
  /* If the SF_UFSrcCheck flag is set, then this function is being called
154675
154691
  ** as part of populating the temp table for an UPDATE...FROM statement.
154676
154692
  ** In this case, it is an error if the target object (pSrc->a[0]) name
@@ -164846,6 +164862,15 @@ SQLITE_PRIVATE SQLITE_NOINLINE void sqlite3WhereRightJoinLoop(
164846
164862
  sqlite3ExprDup(pParse->db, pTerm->pExpr, 0));
164847
164863
  }
164848
164864
  }
164865
+ if( pLevel->iIdxCur ){
164866
+ /* pSubWhere may contain expressions that read from an index on the
164867
+ ** table on the RHS of the right join. All such expressions first test
164868
+ ** if the index is pointing at a NULL row, and if so, read from the
164869
+ ** table cursor instead. So ensure that the index cursor really is
164870
+ ** pointing at a NULL row here, so that no values are read from it during
164871
+ ** the scan of the RHS of the RIGHT join below. */
164872
+ sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
164873
+ }
164849
164874
  pFrom = &uSrc.sSrc;
164850
164875
  pFrom->nSrc = 1;
164851
164876
  pFrom->nAlloc = 1;
@@ -224361,7 +224386,7 @@ static int rbuDeltaApply(
224361
224386
  /* ERROR: copy exceeds output file size */
224362
224387
  return -1;
224363
224388
  }
224364
- if( (int)(ofst+cnt) > lenSrc ){
224389
+ if( (u64)ofst+(u64)cnt > (u64)lenSrc ){
224365
224390
  /* ERROR: copy extends past end of input */
224366
224391
  return -1;
224367
224392
  }
@@ -252648,7 +252673,7 @@ static void fts5DoSecureDelete(
252648
252673
  int iSegid = pSeg->pSeg->iSegid;
252649
252674
  u8 *aPg = pSeg->pLeaf->p;
252650
252675
  int nPg = pSeg->pLeaf->nn;
252651
- int iPgIdx = pSeg->pLeaf->szLeaf;
252676
+ int iPgIdx = pSeg->pLeaf->szLeaf; /* Offset of page footer */
252652
252677
 
252653
252678
  u64 iDelta = 0;
252654
252679
  int iNextOff = 0;
@@ -252727,7 +252752,7 @@ static void fts5DoSecureDelete(
252727
252752
  iSOP += fts5GetVarint32(&aPg[iSOP], nPos);
252728
252753
  }
252729
252754
  assert_nc( iSOP==pSeg->iLeafOffset );
252730
- iNextOff = pSeg->iLeafOffset + pSeg->nPos;
252755
+ iNextOff = iSOP + pSeg->nPos;
252731
252756
  }
252732
252757
  }
252733
252758
 
@@ -260546,7 +260571,7 @@ static void fts5SourceIdFunc(
260546
260571
  ){
260547
260572
  assert( nArg==0 );
260548
260573
  UNUSED_PARAM2(nArg, apUnused);
260549
- sqlite3_result_text(pCtx, "fts5: 2026-01-09 17:27:48 b270f8339eb13b504d0b2ba154ebca966b7dde08e40c3ed7d559749818cb2075", -1, SQLITE_TRANSIENT);
260574
+ sqlite3_result_text(pCtx, "fts5: 2026-03-13 10:38:09 737ae4a34738ffa0c3ff7f9bb18df914dd1cad163f28fd6b6e114a344fe6d618", -1, SQLITE_TRANSIENT);
260550
260575
  }
260551
260576
 
260552
260577
  /*
@@ -266396,10 +266421,10 @@ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
266396
266421
  #define SQLITE3MC_VERSION_H_
266397
266422
 
266398
266423
  #define SQLITE3MC_VERSION_MAJOR 2
266399
- #define SQLITE3MC_VERSION_MINOR 2
266400
- #define SQLITE3MC_VERSION_RELEASE 7
266424
+ #define SQLITE3MC_VERSION_MINOR 3
266425
+ #define SQLITE3MC_VERSION_RELEASE 1
266401
266426
  #define SQLITE3MC_VERSION_SUBRELEASE 0
266402
- #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 2.2.7"
266427
+ #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 2.3.1"
266403
266428
 
266404
266429
  #endif /* SQLITE3MC_VERSION_H_ */
266405
266430
  /*** End of #include "sqlite3mc_version.h" ***/
@@ -266558,12 +266583,12 @@ extern "C" {
266558
266583
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
266559
266584
  ** [sqlite_version()] and [sqlite_source_id()].
266560
266585
  */
266561
- #define SQLITE_VERSION "3.51.2"
266562
- #define SQLITE_VERSION_NUMBER 3051002
266563
- #define SQLITE_SOURCE_ID "2026-01-09 17:27:48 b270f8339eb13b504d0b2ba154ebca966b7dde08e40c3ed7d559749818cb2075"
266586
+ #define SQLITE_VERSION "3.51.3"
266587
+ #define SQLITE_VERSION_NUMBER 3051003
266588
+ #define SQLITE_SOURCE_ID "2026-03-13 10:38:09 737ae4a34738ffa0c3ff7f9bb18df914dd1cad163f28fd6b6e114a344fe6d618"
266564
266589
  #define SQLITE_SCM_BRANCH "branch-3.51"
266565
- #define SQLITE_SCM_TAGS "release version-3.51.2"
266566
- #define SQLITE_SCM_DATETIME "2026-01-09T17:27:48.405Z"
266590
+ #define SQLITE_SCM_TAGS "release version-3.51.3"
266591
+ #define SQLITE_SCM_DATETIME "2026-03-13T10:38:09.694Z"
266567
266592
 
266568
266593
  /*
266569
266594
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -286476,12 +286501,20 @@ void RijndaelInvalidate(Rijndael* rijndael)
286476
286501
  /* --- Visual C/C++ --- */
286477
286502
  #elif defined (_MSC_VER)
286478
286503
 
286504
+ #if defined(_M_ARM64EC)
286505
+ #define HAS_AEGIS_AES_HARDWARE AEGIS_AES_HARDWARE_NEON
286506
+
286507
+ /* Use header <arm64_neon.h> instead of <arm_neon.h> */
286508
+ #ifndef USE_ARM64_NEON_H
286509
+ #define USE_ARM64_NEON_H
286510
+ #endif
286511
+
286479
286512
  /* Architecture: x86 or x86_64 */
286480
- #if (defined(_M_X64) || defined(_M_IX86)) && _MSC_FULL_VER >= 150030729
286513
+ #elif (defined(_M_X64) || defined(_M_IX86)) && _MSC_FULL_VER >= 150030729
286481
286514
  #define HAS_AEGIS_AES_HARDWARE AEGIS_AES_HARDWARE_NI
286482
286515
 
286483
286516
  /* Architecture: ARM 64-bit */
286484
- #elif defined(_M_ARM64)
286517
+ #elif defined(_M_ARM64) || defined(_M_ARM64EC)
286485
286518
  #define HAS_AEGIS_AES_HARDWARE AEGIS_AES_HARDWARE_NEON
286486
286519
 
286487
286520
  /* Use header <arm64_neon.h> instead of <arm_neon.h> */
@@ -288953,6 +288986,39 @@ int aegis_verify_32(const uint8_t *x, const uint8_t *y) __attribute__((warn_unus
288953
288986
  # undef HAVE_VAESINTRIN_H
288954
288987
  # endif
288955
288988
  # endif
288989
+
288990
+ /* target pragmas don't define these flags on clang-cl (an alternative clang driver for Windows) */
288991
+ # if defined(__clang__) && defined(_MSC_BUILD) && defined(_MSC_VER) && \
288992
+ (defined(_M_IX86) || defined(_M_AMD64)) && !defined(__SSE3__)
288993
+ # undef __SSE3__
288994
+ # undef __SSSE3__
288995
+ # undef __SSE4_1__
288996
+ # undef __AVX__
288997
+ # undef __AVX2__
288998
+ # undef __AVX512F__
288999
+ # undef __AES__
289000
+ # undef __VAES__
289001
+
289002
+ # define __SSE3__ 1
289003
+ # define __SSSE3__ 1
289004
+ # define __SSE4_1__ 1
289005
+ # define __AVX__ 1
289006
+ # define __AVX2__ 1
289007
+ # define __AVX512F__ 1
289008
+ # define __AES__ 1
289009
+ # define __VAES__ 1
289010
+ # endif
289011
+
289012
+ #endif
289013
+
289014
+ #ifdef DISABLE_AVX2
289015
+ # undef HAVE_AVXINTRIN_H
289016
+ # undef HAVE_AVX2INTRIN_H
289017
+ # undef HAVE_AVX512FINTRIN_H
289018
+ # undef HAVE_VAESINTRIN_H
289019
+ #endif
289020
+ #ifdef DISABLE_AVX512
289021
+ # undef HAVE_AVX512FINTRIN_H
288956
289022
  #endif
288957
289023
 
288958
289024
  #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
@@ -289226,11 +289292,11 @@ _runtime_arm_cpu_features(CPUFeatures *const cpu_features)
289226
289292
  return -1; /* LCOV_EXCL_LINE */
289227
289293
  #endif
289228
289294
 
289229
- #if defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)
289295
+ #if defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
289230
289296
  cpu_features->has_neon = 1;
289231
289297
  #elif defined(HAVE_ANDROID_GETCPUFEATURES) && defined(ANDROID_CPU_ARM_FEATURE_NEON)
289232
289298
  cpu_features->has_neon = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0x0;
289233
- #elif (defined(__aarch64__) || defined(_M_ARM64)) && defined(AT_HWCAP)
289299
+ #elif (defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)) && defined(AT_HWCAP)
289234
289300
  # ifdef HAVE_GETAUXVAL
289235
289301
  cpu_features->has_neon = (getauxval(AT_HWCAP) & (1L << 1)) != 0;
289236
289302
  # elif defined(HAVE_ELF_AUX_INFO)
@@ -289260,7 +289326,7 @@ _runtime_arm_cpu_features(CPUFeatures *const cpu_features)
289260
289326
 
289261
289327
  #if __ARM_FEATURE_CRYPTO
289262
289328
  cpu_features->has_armcrypto = 1;
289263
- #elif defined(_M_ARM64)
289329
+ #elif defined(_M_ARM64) || defined(_M_ARM64EC)
289264
289330
  cpu_features->has_armcrypto =
289265
289331
  1; /* assuming all CPUs supported by ARM Windows have the crypto extensions */
289266
289332
  #elif defined(__APPLE__) && defined(CPU_TYPE_ARM64) && defined(CPU_SUBTYPE_ARM64E)
@@ -289279,7 +289345,7 @@ _runtime_arm_cpu_features(CPUFeatures *const cpu_features)
289279
289345
  }
289280
289346
  #elif defined(HAVE_ANDROID_GETCPUFEATURES) && defined(ANDROID_CPU_ARM_FEATURE_AES)
289281
289347
  cpu_features->has_armcrypto = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_AES) != 0x0;
289282
- #elif (defined(__aarch64__) || defined(_M_ARM64)) && defined(AT_HWCAP)
289348
+ #elif (defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)) && defined(AT_HWCAP)
289283
289349
  # ifdef HAVE_GETAUXVAL
289284
289350
  cpu_features->has_armcrypto = (getauxval(AT_HWCAP) & (1L << 3)) != 0;
289285
289351
  # elif defined(HAVE_ELF_AUX_INFO)
@@ -296655,6 +296721,10 @@ AEGIS_API_IMPL_LIST_MAC
296655
296721
  ** SPDX-License-Identifier: MIT
296656
296722
  */
296657
296723
 
296724
+ /* #include "../common/aeshardware.h" */
296725
+
296726
+
296727
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
296658
296728
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
296659
296729
 
296660
296730
  #include <errno.h>
@@ -297639,6 +297709,7 @@ AEGIS_API_IMPL_LIST_MAC
297639
297709
  # pragma clang attribute pop
297640
297710
  #endif
297641
297711
 
297712
+ #endif
297642
297713
  #endif
297643
297714
  /*** End of #include "aegis128l/aegis128l_aesni.c" ***/
297644
297715
 
@@ -297651,6 +297722,10 @@ AEGIS_API_IMPL_LIST_MAC
297651
297722
  ** SPDX-License-Identifier: MIT
297652
297723
  */
297653
297724
 
297725
+ /* #include "../common/aeshardware.h" */
297726
+
297727
+
297728
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
297654
297729
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
297655
297730
 
297656
297731
  #include <errno.h>
@@ -298749,6 +298824,7 @@ AEGIS_API_IMPL_LIST_MAC
298749
298824
  # pragma clang attribute pop
298750
298825
  #endif
298751
298826
 
298827
+ #endif
298752
298828
  #endif
298753
298829
  /*** End of #include "aegis128x2/aegis128x2_aesni.c" ***/
298754
298830
 
@@ -298761,6 +298837,10 @@ AEGIS_API_IMPL_LIST_MAC
298761
298837
  ** SPDX-License-Identifier: MIT
298762
298838
  */
298763
298839
 
298840
+ /* #include "../common/aeshardware.h" */
298841
+
298842
+
298843
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
298764
298844
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
298765
298845
 
298766
298846
  #include <errno.h>
@@ -299882,6 +299962,7 @@ AEGIS_API_IMPL_LIST_MAC
299882
299962
  # pragma clang attribute pop
299883
299963
  #endif
299884
299964
 
299965
+ #endif
299885
299966
  #endif
299886
299967
  /*** End of #include "aegis128x4/aegis128x4_aesni.c" ***/
299887
299968
 
@@ -299894,6 +299975,10 @@ AEGIS_API_IMPL_LIST_MAC
299894
299975
  ** SPDX-License-Identifier: MIT
299895
299976
  */
299896
299977
 
299978
+ /* #include "../common/aeshardware.h" */
299979
+
299980
+
299981
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
299897
299982
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
299898
299983
 
299899
299984
  #include <errno.h>
@@ -300860,6 +300945,7 @@ AEGIS_API_IMPL_LIST_MAC
300860
300945
  # pragma clang attribute pop
300861
300946
  #endif
300862
300947
 
300948
+ #endif
300863
300949
  #endif
300864
300950
  /*** End of #include "aegis256/aegis256_aesni.c" ***/
300865
300951
 
@@ -300872,6 +300958,10 @@ AEGIS_API_IMPL_LIST_MAC
300872
300958
  ** SPDX-License-Identifier: MIT
300873
300959
  */
300874
300960
 
300961
+ /* #include "../common/aeshardware.h" */
300962
+
300963
+
300964
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
300875
300965
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
300876
300966
 
300877
300967
  #include <errno.h>
@@ -301960,6 +302050,7 @@ AEGIS_API_IMPL_LIST_MAC
301960
302050
  # pragma clang attribute pop
301961
302051
  #endif
301962
302052
 
302053
+ #endif
301963
302054
  #endif
301964
302055
  /*** End of #include "aegis256x2/aegis256x2_aesni.c" ***/
301965
302056
 
@@ -301972,6 +302063,10 @@ AEGIS_API_IMPL_LIST_MAC
301972
302063
  ** SPDX-License-Identifier: MIT
301973
302064
  */
301974
302065
 
302066
+ /* #include "../common/aeshardware.h" */
302067
+
302068
+
302069
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
301975
302070
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
301976
302071
 
301977
302072
  #include <errno.h>
@@ -303088,6 +303183,7 @@ AEGIS_API_IMPL_LIST_MAC
303088
303183
  # pragma clang attribute pop
303089
303184
  #endif
303090
303185
 
303186
+ #endif
303091
303187
  #endif
303092
303188
  /*** End of #include "aegis256x4/aegis256x4_aesni.c" ***/
303093
303189
 
@@ -303102,6 +303198,10 @@ AEGIS_API_IMPL_LIST_MAC
303102
303198
  ** SPDX-License-Identifier: MIT
303103
303199
  */
303104
303200
 
303201
+ /* #include "../common/aeshardware.h" */
303202
+
303203
+
303204
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
303105
303205
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
303106
303206
 
303107
303207
  #include <errno.h>
@@ -304199,6 +304299,7 @@ AEGIS_API_IMPL_LIST_MAC
304199
304299
 
304200
304300
  #endif /* HAVE_VAESINTRIN_H */
304201
304301
 
304302
+ #endif
304202
304303
  #endif
304203
304304
  /*** End of #include "aegis128x2/aegis128x2_avx2.c" ***/
304204
304305
 
@@ -304211,6 +304312,10 @@ AEGIS_API_IMPL_LIST_MAC
304211
304312
  ** SPDX-License-Identifier: MIT
304212
304313
  */
304213
304314
 
304315
+ /* #include "../common/aeshardware.h" */
304316
+
304317
+
304318
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
304214
304319
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
304215
304320
 
304216
304321
  #include <errno.h>
@@ -305328,6 +305433,7 @@ AEGIS_API_IMPL_LIST_MAC
305328
305433
 
305329
305434
  #endif /* HAVE_VAESINTRIN_H */
305330
305435
 
305436
+ #endif
305331
305437
  #endif
305332
305438
  /*** End of #include "aegis128x4/aegis128x4_avx2.c" ***/
305333
305439
 
@@ -305340,6 +305446,10 @@ AEGIS_API_IMPL_LIST_MAC
305340
305446
  ** SPDX-License-Identifier: MIT
305341
305447
  */
305342
305448
 
305449
+ /* #include "../common/aeshardware.h" */
305450
+
305451
+
305452
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
305343
305453
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
305344
305454
 
305345
305455
  #include <errno.h>
@@ -306427,6 +306537,7 @@ AEGIS_API_IMPL_LIST_MAC
306427
306537
 
306428
306538
  #endif /* HAVE_VAESINTRIN_H */
306429
306539
 
306540
+ #endif
306430
306541
  #endif
306431
306542
  /*** End of #include "aegis256x2/aegis256x2_avx2.c" ***/
306432
306543
 
@@ -306439,6 +306550,10 @@ AEGIS_API_IMPL_LIST_MAC
306439
306550
  ** SPDX-License-Identifier: MIT
306440
306551
  */
306441
306552
 
306553
+ /* #include "../common/aeshardware.h" */
306554
+
306555
+
306556
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
306442
306557
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
306443
306558
 
306444
306559
  #include <errno.h>
@@ -307551,6 +307666,7 @@ AEGIS_API_IMPL_LIST_MAC
307551
307666
 
307552
307667
  #endif /* HAVE_VAESINTRIN_H */
307553
307668
 
307669
+ #endif
307554
307670
  #endif
307555
307671
  /*** End of #include "aegis256x4/aegis256x4_avx2.c" ***/
307556
307672
 
@@ -307565,6 +307681,10 @@ AEGIS_API_IMPL_LIST_MAC
307565
307681
  ** SPDX-License-Identifier: MIT
307566
307682
  */
307567
307683
 
307684
+ /* #include "../common/aeshardware.h" */
307685
+
307686
+
307687
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
307568
307688
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
307569
307689
 
307570
307690
  #include <errno.h>
@@ -308695,6 +308815,7 @@ AEGIS_API_IMPL_LIST_MAC
308695
308815
 
308696
308816
  #endif /* HAVE_VAESINTRIN_H */
308697
308817
 
308818
+ #endif
308698
308819
  #endif
308699
308820
  /*** End of #include "aegis128x4/aegis128x4_avx512.c" ***/
308700
308821
 
@@ -308707,6 +308828,10 @@ AEGIS_API_IMPL_LIST_MAC
308707
308828
  ** SPDX-License-Identifier: MIT
308708
308829
  */
308709
308830
 
308831
+ /* #include "../common/aeshardware.h" */
308832
+
308833
+
308834
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_NI
308710
308835
  #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_AMD64)
308711
308836
 
308712
308837
  #include <errno.h>
@@ -309832,6 +309957,7 @@ AEGIS_API_IMPL_LIST_MAC
309832
309957
 
309833
309958
  #endif /* HAVE_VAESINTRIN_H */
309834
309959
 
309960
+ #endif
309835
309961
  #endif
309836
309962
  /*** End of #include "aegis256x4/aegis256x4_avx512.c" ***/
309837
309963
 
@@ -309846,6 +309972,10 @@ AEGIS_API_IMPL_LIST_MAC
309846
309972
  ** SPDX-License-Identifier: MIT
309847
309973
  */
309848
309974
 
309975
+ /* #include "../common/aeshardware.h" */
309976
+
309977
+
309978
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC
309849
309979
  #if defined(__ALTIVEC__) && defined(__CRYPTO__)
309850
309980
 
309851
309981
  #include <errno.h>
@@ -310826,6 +310956,7 @@ AEGIS_API_IMPL_LIST_MAC
310826
310956
  # pragma clang attribute pop
310827
310957
  #endif
310828
310958
 
310959
+ #endif
310829
310960
  #endif
310830
310961
  /*** End of #include "aegis128l/aegis128l_altivec.c" ***/
310831
310962
 
@@ -310838,6 +310969,10 @@ AEGIS_API_IMPL_LIST_MAC
310838
310969
  ** SPDX-License-Identifier: MIT
310839
310970
  */
310840
310971
 
310972
+ /* #include "../common/aeshardware.h" */
310973
+
310974
+
310975
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC
310841
310976
  #if defined(__ALTIVEC__) && defined(__CRYPTO__)
310842
310977
 
310843
310978
  #include <errno.h>
@@ -311931,6 +312066,7 @@ AEGIS_API_IMPL_LIST_MAC
311931
312066
  # pragma clang attribute pop
311932
312067
  #endif
311933
312068
 
312069
+ #endif
311934
312070
  #endif
311935
312071
  /*** End of #include "aegis128x2/aegis128x2_altivec.c" ***/
311936
312072
 
@@ -311943,6 +312079,10 @@ AEGIS_API_IMPL_LIST_MAC
311943
312079
  ** SPDX-License-Identifier: MIT
311944
312080
  */
311945
312081
 
312082
+ /* #include "../common/aeshardware.h" */
312083
+
312084
+
312085
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC
311946
312086
  #if defined(__ALTIVEC__) && defined(__CRYPTO__)
311947
312087
 
311948
312088
  #include <errno.h>
@@ -313058,6 +313198,7 @@ AEGIS_API_IMPL_LIST_MAC
313058
313198
  # pragma clang attribute pop
313059
313199
  #endif
313060
313200
 
313201
+ #endif
313061
313202
  #endif
313062
313203
  /*** End of #include "aegis128x4/aegis128x4_altivec.c" ***/
313063
313204
 
@@ -313070,6 +313211,10 @@ AEGIS_API_IMPL_LIST_MAC
313070
313211
  ** SPDX-License-Identifier: MIT
313071
313212
  */
313072
313213
 
313214
+ /* #include "../common/aeshardware.h" */
313215
+
313216
+
313217
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC
313073
313218
  #if defined(__ALTIVEC__) && defined(__CRYPTO__)
313074
313219
 
313075
313220
  #include <errno.h>
@@ -314034,6 +314179,7 @@ AEGIS_API_IMPL_LIST_MAC
314034
314179
  # pragma clang attribute pop
314035
314180
  #endif
314036
314181
 
314182
+ #endif
314037
314183
  #endif
314038
314184
  /*** End of #include "aegis256/aegis256_altivec.c" ***/
314039
314185
 
@@ -314046,6 +314192,10 @@ AEGIS_API_IMPL_LIST_MAC
314046
314192
  ** SPDX-License-Identifier: MIT
314047
314193
  */
314048
314194
 
314195
+ /* #include "../common/aeshardware.h" */
314196
+
314197
+
314198
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC
314049
314199
  #if defined(__ALTIVEC__) && defined(__CRYPTO__)
314050
314200
 
314051
314201
  #include <errno.h>
@@ -315133,6 +315283,7 @@ AEGIS_API_IMPL_LIST_MAC
315133
315283
  # pragma clang attribute pop
315134
315284
  #endif
315135
315285
 
315286
+ #endif
315136
315287
  #endif
315137
315288
  /*** End of #include "aegis256x2/aegis256x2_altivec.c" ***/
315138
315289
 
@@ -315145,6 +315296,10 @@ AEGIS_API_IMPL_LIST_MAC
315145
315296
  ** SPDX-License-Identifier: MIT
315146
315297
  */
315147
315298
 
315299
+ /* #include "../common/aeshardware.h" */
315300
+
315301
+
315302
+ #if HAS_AEGIS_AES_HARDWARE == AEGIS_AES_HARDWARE_ALTIVEC
315148
315303
  #if defined(__ALTIVEC__) && defined(__CRYPTO__)
315149
315304
 
315150
315305
  #include <errno.h>
@@ -316258,6 +316413,7 @@ AEGIS_API_IMPL_LIST_MAC
316258
316413
  # pragma clang attribute pop
316259
316414
  #endif
316260
316415
 
316416
+ #endif
316261
316417
  #endif
316262
316418
  /*** End of #include "aegis256x4/aegis256x4_altivec.c" ***/
316263
316419
 
@@ -329471,6 +329627,8 @@ GenerateKeyChaCha20Cipher(void* cipher, char* userPassword, int passwordLength,
329471
329627
  else
329472
329628
  {
329473
329629
  memcpy(chacha20Cipher->m_salt, cipherSalt, SALTLENGTH_CHACHA20);
329630
+ if (chacha20Cipher->m_plaintextHeaderSize > 0)
329631
+ keyOnly = 0;
329474
329632
  }
329475
329633
 
329476
329634
  /* Bypass key derivation, if raw key (and optionally salt) are given */
@@ -329941,6 +330099,8 @@ GenerateKeySQLCipherCipher(void* cipher, char* userPassword, int passwordLength,
329941
330099
  else
329942
330100
  {
329943
330101
  memcpy(sqlCipherCipher->m_salt, cipherSalt, SALTLENGTH_SQLCIPHER);
330102
+ if (sqlCipherCipher->m_plaintextHeaderSize > 0)
330103
+ keyOnly = 0;
329944
330104
  }
329945
330105
 
329946
330106
  /* Bypass key derivation, if raw key (and optionally salt) are given */
@@ -331752,6 +331912,8 @@ GenerateKeyAscon128Cipher(void* cipher, char* userPassword, int passwordLength,
331752
331912
  else
331753
331913
  {
331754
331914
  memcpy(ascon128Cipher->m_salt, cipherSalt, SALTLENGTH_ASCON128);
331915
+ if (ascon128Cipher->m_plaintextHeaderSize > 0)
331916
+ keyOnly = 0;
331755
331917
  }
331756
331918
 
331757
331919
  /* Bypass key derivation, if raw key (and optionally salt) are given */
@@ -332233,6 +332395,8 @@ GenerateKeyAegisCipher(void* cipher, char* userPassword, int passwordLength, int
332233
332395
  else
332234
332396
  {
332235
332397
  memcpy(aegisCipher->m_salt, cipherSalt, SALTLENGTH_AEGIS);
332398
+ if (aegisCipher->m_plaintextHeaderSize > 0)
332399
+ keyOnly = 0;
332236
332400
  }
332237
332401
 
332238
332402
  /* Bypass key derivation, if raw key (and optionally salt) are given */
@@ -334584,7 +334748,7 @@ sqlite3mcBtreeSetPageSize(Btree* p, int pageSize, int nReserve, int iFix)
334584
334748
  ** Change 4: Call sqlite3mcBtreeSetPageSize instead of sqlite3BtreeSetPageSize for main database
334585
334749
  ** (sqlite3mcBtreeSetPageSize allows to reduce the number of reserved bytes)
334586
334750
  **
334587
- ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.51.2 amalgamation.
334751
+ ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.51.3 amalgamation.
334588
334752
  */
334589
334753
  SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3mcRunVacuumForRekey(
334590
334754
  char **pzErrMsg, /* Write error message here */
@@ -338468,8 +338632,8 @@ int sqlite3_csv_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines* p
338468
338632
  ** schema= parameter, like this:
338469
338633
  **
338470
338634
  ** CREATE VIRTUAL TABLE temp.csv2 USING csv(
338471
- ** filename = "../http.log",
338472
- ** schema = "CREATE TABLE x(date,ipaddr,url,referrer,userAgent)"
338635
+ ** filename = '../http.log',
338636
+ ** schema = 'CREATE TABLE x(date,ipaddr,url,referrer,userAgent)'
338473
338637
  ** );
338474
338638
  **
338475
338639
  ** Instead of specifying a file, the text of the CSV can be loaded using
@@ -342457,6 +342621,8 @@ SQLITE_EXTENSION_INIT1
342457
342621
  # include <utime.h>
342458
342622
  # include <sys/time.h>
342459
342623
  # define STRUCT_STAT struct stat
342624
+ # include <limits.h>
342625
+ # include <stdlib.h>
342460
342626
  #else
342461
342627
  /* # include "windirent.h" */
342462
342628
  /*** Begin of # include "windirent.h" ***/
@@ -342629,6 +342795,8 @@ static struct dirent *readdir(DIR *pDir){
342629
342795
  # define STRUCT_STAT struct _stat
342630
342796
  # define chmod(path,mode) fileio_chmod(path,mode)
342631
342797
  # define mkdir(path,mode) fileio_mkdir(path)
342798
+ extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
342799
+ extern char *sqlite3_win32_unicode_to_utf8(LPCWSTR);
342632
342800
  #endif
342633
342801
  #include <time.h>
342634
342802
  #include <errno.h>
@@ -342660,12 +342828,9 @@ static struct dirent *readdir(DIR *pDir){
342660
342828
  */
342661
342829
  #if defined(_WIN32) || defined(WIN32)
342662
342830
  static int fileio_chmod(const char *zPath, int pmode){
342663
- sqlite3_int64 sz = strlen(zPath);
342664
- wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
342665
342831
  int rc;
342832
+ wchar_t *b1 = sqlite3_win32_utf8_to_unicode(zPath);
342666
342833
  if( b1==0 ) return -1;
342667
- sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
342668
- b1[sz] = 0;
342669
342834
  rc = _wchmod(b1, pmode);
342670
342835
  sqlite3_free(b1);
342671
342836
  return rc;
@@ -342677,12 +342842,9 @@ static int fileio_chmod(const char *zPath, int pmode){
342677
342842
  */
342678
342843
  #if defined(_WIN32) || defined(WIN32)
342679
342844
  static int fileio_mkdir(const char *zPath){
342680
- sqlite3_int64 sz = strlen(zPath);
342681
- wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
342682
342845
  int rc;
342846
+ wchar_t *b1 = sqlite3_win32_utf8_to_unicode(zPath);
342683
342847
  if( b1==0 ) return -1;
342684
- sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
342685
- b1[sz] = 0;
342686
342848
  rc = _wmkdir(b1);
342687
342849
  sqlite3_free(b1);
342688
342850
  return rc;
@@ -342795,50 +342957,7 @@ static sqlite3_uint64 fileTimeToUnixTime(
342795
342957
 
342796
342958
  return (fileIntervals.QuadPart - epochIntervals.QuadPart) / 10000000;
342797
342959
  }
342798
-
342799
-
342800
- #if defined(FILEIO_WIN32_DLL) && (defined(_WIN32) || defined(WIN32))
342801
- # /* To allow a standalone DLL, use this next replacement function: */
342802
- # undef sqlite3_win32_utf8_to_unicode
342803
- # define sqlite3_win32_utf8_to_unicode utf8_to_utf16
342804
- #
342805
- LPWSTR utf8_to_utf16(const char *z){
342806
- int nAllot = MultiByteToWideChar(CP_UTF8, 0, z, -1, NULL, 0);
342807
- LPWSTR rv = sqlite3_malloc(nAllot * sizeof(WCHAR));
342808
- if( rv!=0 && 0 < MultiByteToWideChar(CP_UTF8, 0, z, -1, rv, nAllot) )
342809
- return rv;
342810
- sqlite3_free(rv);
342811
- return 0;
342812
- }
342813
- #endif
342814
-
342815
- /*
342816
- ** This function attempts to normalize the time values found in the stat()
342817
- ** buffer to UTC. This is necessary on Win32, where the runtime library
342818
- ** appears to return these values as local times.
342819
- */
342820
- static void statTimesToUtc(
342821
- const char *zPath,
342822
- STRUCT_STAT *pStatBuf
342823
- ){
342824
- HANDLE hFindFile;
342825
- WIN32_FIND_DATAW fd;
342826
- LPWSTR zUnicodeName;
342827
- extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
342828
- zUnicodeName = sqlite3_win32_utf8_to_unicode(zPath);
342829
- if( zUnicodeName ){
342830
- memset(&fd, 0, sizeof(WIN32_FIND_DATAW));
342831
- hFindFile = FindFirstFileW(zUnicodeName, &fd);
342832
- if( hFindFile!=NULL ){
342833
- pStatBuf->st_ctime = (time_t)fileTimeToUnixTime(&fd.ftCreationTime);
342834
- pStatBuf->st_atime = (time_t)fileTimeToUnixTime(&fd.ftLastAccessTime);
342835
- pStatBuf->st_mtime = (time_t)fileTimeToUnixTime(&fd.ftLastWriteTime);
342836
- FindClose(hFindFile);
342837
- }
342838
- sqlite3_free(zUnicodeName);
342839
- }
342840
- }
342841
- #endif
342960
+ #endif /* _WIN32 */
342842
342961
 
342843
342962
  /*
342844
342963
  ** This function is used in place of stat(). On Windows, special handling
@@ -342850,14 +342969,22 @@ static int fileStat(
342850
342969
  STRUCT_STAT *pStatBuf
342851
342970
  ){
342852
342971
  #if defined(_WIN32)
342853
- sqlite3_int64 sz = strlen(zPath);
342854
- wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
342855
342972
  int rc;
342973
+ wchar_t *b1 = sqlite3_win32_utf8_to_unicode(zPath);
342856
342974
  if( b1==0 ) return 1;
342857
- sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
342858
- b1[sz] = 0;
342859
342975
  rc = _wstat(b1, pStatBuf);
342860
- if( rc==0 ) statTimesToUtc(zPath, pStatBuf);
342976
+ if( rc==0 ){
342977
+ HANDLE hFindFile;
342978
+ WIN32_FIND_DATAW fd;
342979
+ memset(&fd, 0, sizeof(WIN32_FIND_DATAW));
342980
+ hFindFile = FindFirstFileW(b1, &fd);
342981
+ if( hFindFile!=NULL ){
342982
+ pStatBuf->st_ctime = (time_t)fileTimeToUnixTime(&fd.ftCreationTime);
342983
+ pStatBuf->st_atime = (time_t)fileTimeToUnixTime(&fd.ftLastAccessTime);
342984
+ pStatBuf->st_mtime = (time_t)fileTimeToUnixTime(&fd.ftLastWriteTime);
342985
+ FindClose(hFindFile);
342986
+ }
342987
+ }
342861
342988
  sqlite3_free(b1);
342862
342989
  return rc;
342863
342990
  #else
@@ -342989,7 +343116,6 @@ static int writeFile(
342989
343116
 
342990
343117
  if( mtime>=0 ){
342991
343118
  #if defined(_WIN32)
342992
- #if !SQLITE_OS_WINRT
342993
343119
  /* Windows */
342994
343120
  FILETIME lastAccess;
342995
343121
  FILETIME lastWrite;
@@ -343020,7 +343146,6 @@ static int writeFile(
343020
343146
  }else{
343021
343147
  return 1;
343022
343148
  }
343023
- #endif
343024
343149
  #elif defined(AT_FDCWD) && 0 /* utimensat() is not universally available */
343025
343150
  /* Recent unix */
343026
343151
  struct timespec times[2];
@@ -343624,6 +343749,154 @@ static int fsdirRegister(sqlite3 *db){
343624
343749
  # define fsdirRegister(x) SQLITE_OK
343625
343750
  #endif
343626
343751
 
343752
+ /*
343753
+ ** This version of realpath() works on any system. The string
343754
+ ** returned is held in memory allocated using sqlite3_malloc64().
343755
+ ** The caller is responsible for calling sqlite3_free().
343756
+ */
343757
+ static char *portable_realpath(const char *zPath){
343758
+ #if !defined(_WIN32) /* BEGIN unix */
343759
+
343760
+ char *zOut = 0; /* Result */
343761
+ char *z; /* Temporary buffer */
343762
+ #if defined(PATH_MAX)
343763
+ char zBuf[PATH_MAX+1]; /* Space for the temporary buffer */
343764
+ #endif
343765
+
343766
+ if( zPath==0 ) return 0;
343767
+ #if defined(PATH_MAX)
343768
+ z = realpath(zPath, zBuf);
343769
+ if( z ){
343770
+ zOut = sqlite3_mprintf("%s", zBuf);
343771
+ }
343772
+ #endif /* defined(PATH_MAX) */
343773
+ if( zOut==0 ){
343774
+ /* Try POSIX.1-2008 malloc behavior */
343775
+ z = realpath(zPath, NULL);
343776
+ if( z ){
343777
+ zOut = sqlite3_mprintf("%s", z);
343778
+ free(z);
343779
+ }
343780
+ }
343781
+ return zOut;
343782
+
343783
+ #else /* End UNIX, Begin WINDOWS */
343784
+
343785
+ wchar_t *zPath16; /* UTF16 translation of zPath */
343786
+ char *zOut = 0; /* Result */
343787
+ wchar_t *z = 0; /* Temporary buffer */
343788
+
343789
+ if( zPath==0 ) return 0;
343790
+
343791
+ zPath16 = sqlite3_win32_utf8_to_unicode(zPath);
343792
+ if( zPath16==0 ) return 0;
343793
+ z = _wfullpath(NULL, zPath16, 0);
343794
+ sqlite3_free(zPath16);
343795
+ if( z ){
343796
+ zOut = sqlite3_win32_unicode_to_utf8(z);
343797
+ free(z);
343798
+ }
343799
+ return zOut;
343800
+
343801
+ #endif /* End WINDOWS, Begin common code */
343802
+ }
343803
+
343804
+ /*
343805
+ ** SQL function: realpath(X)
343806
+ **
343807
+ ** Try to convert file or pathname X into its real, absolute pathname.
343808
+ ** Return NULL if unable.
343809
+ **
343810
+ ** The file or directory X is not required to exist. The answer is formed
343811
+ ** by calling system realpath() on the prefix of X that does exist and
343812
+ ** appending the tail of X that does not (yet) exist.
343813
+ */
343814
+ static void realpathFunc(
343815
+ sqlite3_context *context,
343816
+ int argc,
343817
+ sqlite3_value **argv
343818
+ ){
343819
+ const char *zPath; /* Original input path */
343820
+ char *zCopy; /* An editable copy of zPath */
343821
+ char *zOut; /* The result */
343822
+ char cSep = 0; /* Separator turned into \000 */
343823
+ size_t len; /* Prefix length before cSep */
343824
+ #ifdef _WIN32
343825
+ const int isWin = 1;
343826
+ #else
343827
+ const int isWin = 0;
343828
+ #endif
343829
+
343830
+ (void)argc;
343831
+ zPath = (const char*)sqlite3_value_text(argv[0]);
343832
+ if( zPath==0 ) return;
343833
+ if( zPath[0]==0 ) zPath = ".";
343834
+ zCopy = sqlite3_mprintf("%s",zPath);
343835
+ len = strlen(zCopy);
343836
+ while( len>1 && (zCopy[len-1]=='/' || (isWin && zCopy[len-1]=='\\')) ){
343837
+ len--;
343838
+ }
343839
+ zCopy[len] = 0;
343840
+ while( 1 /*exit-by-break*/ ){
343841
+ zOut = portable_realpath(zCopy);
343842
+ zCopy[len] = cSep;
343843
+ if( zOut ){
343844
+ if( cSep ){
343845
+ zOut = sqlite3_mprintf("%z%s",zOut,&zCopy[len]);
343846
+ }
343847
+ break;
343848
+ }else{
343849
+ size_t i = len-1;
343850
+ while( i>0 ){
343851
+ if( zCopy[i]=='/' || (isWin && zCopy[i]=='\\') ) break;
343852
+ i--;
343853
+ }
343854
+ if( i<=0 ){
343855
+ if( zCopy[0]=='/' ){
343856
+ zOut = zCopy;
343857
+ zCopy = 0;
343858
+ }else if( (zOut = portable_realpath("."))!=0 ){
343859
+ zOut = sqlite3_mprintf("%z/%s", zOut, zCopy);
343860
+ }
343861
+ break;
343862
+ }
343863
+ cSep = zCopy[i];
343864
+ zCopy[i] = 0;
343865
+ len = i;
343866
+ }
343867
+ }
343868
+ sqlite3_free(zCopy);
343869
+ if( zOut ){
343870
+ /* Simplify any "/./" or "/../" that might have snuck into the
343871
+ ** pathname due to appending of zCopy. We only have to consider
343872
+ ** unix "/" separators, because the _wfilepath() system call on
343873
+ ** Windows will have already done this simplification for us. */
343874
+ size_t i, j, n;
343875
+ n = strlen(zOut);
343876
+ for(i=j=0; i<n; i++){
343877
+ if( zOut[i]=='/' ){
343878
+ if( zOut[i+1]=='/' ) continue;
343879
+ if( zOut[i+1]=='.' && i+2<n && zOut[i+2]=='/' ){
343880
+ i += 1;
343881
+ continue;
343882
+ }
343883
+ if( zOut[i+1]=='.' && i+3<n && zOut[i+2]=='.' && zOut[i+3]=='/' ){
343884
+ while( j>0 && zOut[j-1]!='/' ){ j--; }
343885
+ if( j>0 ){ j--; }
343886
+ i += 2;
343887
+ continue;
343888
+ }
343889
+ }
343890
+ zOut[j++] = zOut[i];
343891
+ }
343892
+ zOut[j] = 0;
343893
+
343894
+ /* Return the result */
343895
+ sqlite3_result_text(context, zOut, -1, sqlite3_free);
343896
+ }
343897
+ }
343898
+
343899
+
343627
343900
  #ifndef SQLITE_API
343628
343901
  #define SQLITE_API
343629
343902
  #endif
@@ -343651,6 +343924,11 @@ int sqlite3_fileio_init(
343651
343924
  if( rc==SQLITE_OK ){
343652
343925
  rc = fsdirRegister(db);
343653
343926
  }
343927
+ if( rc==SQLITE_OK ){
343928
+ rc = sqlite3_create_function(db, "realpath", 1,
343929
+ SQLITE_UTF8, 0,
343930
+ realpathFunc, 0, 0);
343931
+ }
343654
343932
  return rc;
343655
343933
  }
343656
343934
  /*** End of #include "fileio.c" ***/
@@ -344900,7 +345178,7 @@ int sqlite3_regexp_init(sqlite3* db, char** pzErrMsg, const sqlite3_api_routines
344900
345178
  ** ^X X occurring at the beginning of the string
344901
345179
  ** X$ X occurring at the end of the string
344902
345180
  ** . Match any single character
344903
- ** \c Character c where c is one of \{}()[]|*+?.
345181
+ ** \c Character c where c is one of \{}()[]|*+?-.
344904
345182
  ** \c C-language escapes for c in afnrtv. ex: \t or \n
344905
345183
  ** \uXXXX Where XXXX is exactly 4 hex digits, unicode value XXXX
344906
345184
  ** \xXX Where XX is exactly 2 hex digits, unicode value XX
@@ -345286,7 +345564,7 @@ static int re_hex(int c, int *pV){
345286
345564
  ** return its interpretation.
345287
345565
  */
345288
345566
  static unsigned re_esc_char(ReCompiled *p){
345289
- static const char zEsc[] = "afnrtv\\()*.+?[$^{|}]";
345567
+ static const char zEsc[] = "afnrtv\\()*.+?[$^{|}]-";
345290
345568
  static const char zTrans[] = "\a\f\n\r\t\v";
345291
345569
  int i, v = 0;
345292
345570
  char c;
@@ -345609,11 +345887,18 @@ static const char *re_compile(
345609
345887
  }
345610
345888
 
345611
345889
  /*
345612
- ** Compute a reasonable limit on the length of the REGEXP NFA.
345890
+ ** The value of LIMIT_MAX_PATTERN_LENGTH.
345613
345891
  */
345614
345892
  static int re_maxlen(sqlite3_context *context){
345615
345893
  sqlite3 *db = sqlite3_context_db_handle(context);
345616
- return 75 + sqlite3_limit(db, SQLITE_LIMIT_LIKE_PATTERN_LENGTH,-1)/2;
345894
+ return sqlite3_limit(db, SQLITE_LIMIT_LIKE_PATTERN_LENGTH,-1);
345895
+ }
345896
+
345897
+ /*
345898
+ ** Maximum NFA size given a maximum pattern length.
345899
+ */
345900
+ static int re_maxnfa(int mxlen){
345901
+ return 75+mxlen/2;
345617
345902
  }
345618
345903
 
345619
345904
  /*
@@ -345639,10 +345924,17 @@ static void re_sql_func(
345639
345924
  (void)argc; /* Unused */
345640
345925
  pRe = sqlite3_get_auxdata(context, 0);
345641
345926
  if( pRe==0 ){
345927
+ int mxLen = re_maxlen(context);
345928
+ int nPattern;
345642
345929
  zPattern = (const char*)sqlite3_value_text(argv[0]);
345643
345930
  if( zPattern==0 ) return;
345644
- zErr = re_compile(&pRe, zPattern, re_maxlen(context),
345645
- sqlite3_user_data(context)!=0);
345931
+ nPattern = sqlite3_value_bytes(argv[0]);
345932
+ if( nPattern>mxLen ){
345933
+ zErr = "REGEXP pattern too big";
345934
+ }else{
345935
+ zErr = re_compile(&pRe, zPattern, re_maxnfa(mxLen),
345936
+ sqlite3_user_data(context)!=0);
345937
+ }
345646
345938
  if( zErr ){
345647
345939
  re_free(pRe);
345648
345940
  sqlite3_result_error(context, zErr, -1);
@@ -345708,7 +346000,7 @@ static void re_bytecode_func(
345708
346000
 
345709
346001
  zPattern = (const char*)sqlite3_value_text(argv[0]);
345710
346002
  if( zPattern==0 ) return;
345711
- zErr = re_compile(&pRe, zPattern, re_maxlen(context),
346003
+ zErr = re_compile(&pRe, zPattern, re_maxnfa(re_maxlen(context)),
345712
346004
  sqlite3_user_data(context)!=0);
345713
346005
  if( zErr ){
345714
346006
  re_free(pRe);
@@ -355597,7 +355889,7 @@ static int zipfileConnect(
355597
355889
 
355598
355890
  rc = sqlite3_declare_vtab(db, ZIPFILE_SCHEMA);
355599
355891
  if( rc==SQLITE_OK ){
355600
- pNew = (ZipfileTab*)sqlite3_malloc64((sqlite3_int64)nByte+nFile);
355892
+ pNew = (ZipfileTab*)sqlite3_malloc64((i64)nByte+nFile);
355601
355893
  if( pNew==0 ) return SQLITE_NOMEM;
355602
355894
  memset(pNew, 0, nByte+nFile);
355603
355895
  pNew->db = db;
@@ -355743,14 +356035,15 @@ static void zipfileCursorErr(ZipfileCsr *pCsr, const char *zFmt, ...){
355743
356035
  static int zipfileReadData(
355744
356036
  FILE *pFile, /* Read from this file */
355745
356037
  u8 *aRead, /* Read into this buffer */
355746
- int nRead, /* Number of bytes to read */
356038
+ i64 nRead, /* Number of bytes to read */
355747
356039
  i64 iOff, /* Offset to read from */
355748
356040
  char **pzErrmsg /* OUT: Error message (from sqlite3_malloc) */
355749
356041
  ){
355750
356042
  size_t n;
355751
356043
  fseek(pFile, (long)iOff, SEEK_SET);
355752
- n = fread(aRead, 1, nRead, pFile);
355753
- if( (int)n!=nRead ){
356044
+ n = fread(aRead, 1, (long)nRead, pFile);
356045
+ if( n!=(size_t)nRead ){
356046
+ sqlite3_free(*pzErrmsg);
355754
356047
  *pzErrmsg = sqlite3_mprintf("error in fread()");
355755
356048
  return SQLITE_ERROR;
355756
356049
  }
@@ -355767,7 +356060,7 @@ static int zipfileAppendData(
355767
356060
  fseek(pTab->pWriteFd, (long)pTab->szCurrent, SEEK_SET);
355768
356061
  n = fwrite(aWrite, 1, nWrite, pTab->pWriteFd);
355769
356062
  if( (int)n!=nWrite ){
355770
- pTab->base.zErrMsg = sqlite3_mprintf("error in fwrite()");
356063
+ zipfileTableErr(pTab,"error in fwrite()");
355771
356064
  return SQLITE_ERROR;
355772
356065
  }
355773
356066
  pTab->szCurrent += nWrite;
@@ -355908,7 +356201,12 @@ static int zipfileScanExtra(u8 *aExtra, int nExtra, u32 *pmTime){
355908
356201
  u8 *p = aExtra;
355909
356202
  u8 *pEnd = &aExtra[nExtra];
355910
356203
 
355911
- while( p<pEnd ){
356204
+ /* Stop when there are less than 9 bytes left to scan in the buffer. This
356205
+ ** is because the timestamp field requires exactly 9 bytes - 4 bytes of
356206
+ ** header fields and 5 bytes of data. If there are less than 9 bytes
356207
+ ** remaining, either it is some other field or else the extra data
356208
+ ** is corrupt. Either way, do not process it. */
356209
+ while( p+(2*sizeof(u16) + 1 + sizeof(u32))<=pEnd ){
355912
356210
  u16 id = zipfileRead16(p);
355913
356211
  u16 nByte = zipfileRead16(p);
355914
356212
 
@@ -356014,6 +356312,7 @@ static void zipfileMtimeToDos(ZipfileCDS *pCds, u32 mUnixTime){
356014
356312
  ** generic corruption message and return SQLITE_CORRUPT;
356015
356313
  */
356016
356314
  static int zipfileCorrupt(char **pzErr){
356315
+ sqlite3_free(*pzErr);
356017
356316
  *pzErr = sqlite3_mprintf("zip archive is corrupt");
356018
356317
  return SQLITE_CORRUPT;
356019
356318
  }
@@ -356032,7 +356331,7 @@ static int zipfileCorrupt(char **pzErr){
356032
356331
  static int zipfileGetEntry(
356033
356332
  ZipfileTab *pTab, /* Store any error message here */
356034
356333
  const u8 *aBlob, /* Pointer to in-memory file image */
356035
- int nBlob, /* Size of aBlob[] in bytes */
356334
+ i64 nBlob, /* Size of aBlob[] in bytes */
356036
356335
  FILE *pFile, /* If aBlob==0, read from this file */
356037
356336
  i64 iOff, /* Offset of CDS record */
356038
356337
  ZipfileEntry **ppEntry /* OUT: Pointer to new object */
@@ -356072,7 +356371,7 @@ static int zipfileGetEntry(
356072
356371
  memset(pNew, 0, sizeof(ZipfileEntry));
356073
356372
  rc = zipfileReadCDS(aRead, &pNew->cds);
356074
356373
  if( rc!=SQLITE_OK ){
356075
- *pzErr = sqlite3_mprintf("failed to read CDS at offset %lld", iOff);
356374
+ zipfileTableErr(pTab, "failed to read CDS at offset %lld", iOff);
356076
356375
  }else if( aBlob==0 ){
356077
356376
  rc = zipfileReadData(
356078
356377
  pFile, aRead, nExtra+nFile, iOff+ZIPFILE_CDS_FIXED_SZ, pzErr
@@ -356104,14 +356403,15 @@ static int zipfileGetEntry(
356104
356403
  rc = zipfileReadData(pFile, aRead, szFix, pNew->cds.iOffset, pzErr);
356105
356404
  }else{
356106
356405
  aRead = (u8*)&aBlob[pNew->cds.iOffset];
356107
- if( (pNew->cds.iOffset + ZIPFILE_LFH_FIXED_SZ)>nBlob ){
356406
+ if( ((i64)pNew->cds.iOffset + ZIPFILE_LFH_FIXED_SZ)>nBlob ){
356108
356407
  rc = zipfileCorrupt(pzErr);
356109
356408
  }
356110
356409
  }
356111
356410
 
356411
+ memset(&lfh, 0, sizeof(lfh));
356112
356412
  if( rc==SQLITE_OK ) rc = zipfileReadLFH(aRead, &lfh);
356113
356413
  if( rc==SQLITE_OK ){
356114
- pNew->iDataOff = pNew->cds.iOffset + ZIPFILE_LFH_FIXED_SZ;
356414
+ pNew->iDataOff = (i64)pNew->cds.iOffset + ZIPFILE_LFH_FIXED_SZ;
356115
356415
  pNew->iDataOff += lfh.nFile + lfh.nExtra;
356116
356416
  if( aBlob && pNew->cds.szCompressed ){
356117
356417
  if( pNew->iDataOff + pNew->cds.szCompressed > nBlob ){
@@ -356122,7 +356422,7 @@ static int zipfileGetEntry(
356122
356422
  }
356123
356423
  }
356124
356424
  }else{
356125
- *pzErr = sqlite3_mprintf("failed to read LFH at offset %d",
356425
+ zipfileTableErr(pTab, "failed to read LFH at offset %d",
356126
356426
  (int)pNew->cds.iOffset
356127
356427
  );
356128
356428
  }
@@ -356146,7 +356446,7 @@ static int zipfileNext(sqlite3_vtab_cursor *cur){
356146
356446
  int rc = SQLITE_OK;
356147
356447
 
356148
356448
  if( pCsr->pFile ){
356149
- i64 iEof = pCsr->eocd.iOffset + pCsr->eocd.nSize;
356449
+ i64 iEof = (i64)pCsr->eocd.iOffset + (i64)pCsr->eocd.nSize;
356150
356450
  zipfileEntryFree(pCsr->pCurrent);
356151
356451
  pCsr->pCurrent = 0;
356152
356452
  if( pCsr->iNextOff>=iEof ){
@@ -356212,7 +356512,7 @@ static void zipfileInflate(
356212
356512
  if( err!=Z_STREAM_END ){
356213
356513
  zipfileCtxErrorMsg(pCtx, "inflate() failed (%d)", err);
356214
356514
  }else{
356215
- sqlite3_result_blob(pCtx, aRes, nOut, zipfileFree);
356515
+ sqlite3_result_blob(pCtx, aRes, (int)str.total_out, zipfileFree);
356216
356516
  aRes = 0;
356217
356517
  }
356218
356518
  }
@@ -356384,12 +356684,12 @@ static int zipfileEof(sqlite3_vtab_cursor *cur){
356384
356684
  static int zipfileReadEOCD(
356385
356685
  ZipfileTab *pTab, /* Return errors here */
356386
356686
  const u8 *aBlob, /* Pointer to in-memory file image */
356387
- int nBlob, /* Size of aBlob[] in bytes */
356687
+ i64 nBlob, /* Size of aBlob[] in bytes */
356388
356688
  FILE *pFile, /* Read from this file if aBlob==0 */
356389
356689
  ZipfileEOCD *pEOCD /* Object to populate */
356390
356690
  ){
356391
356691
  u8 *aRead = pTab->aBuffer; /* Temporary buffer */
356392
- int nRead; /* Bytes to read from file */
356692
+ i64 nRead; /* Bytes to read from file */
356393
356693
  int rc = SQLITE_OK;
356394
356694
 
356395
356695
  memset(pEOCD, 0, sizeof(ZipfileEOCD));
@@ -356410,7 +356710,7 @@ static int zipfileReadEOCD(
356410
356710
  }
356411
356711
 
356412
356712
  if( rc==SQLITE_OK ){
356413
- int i;
356713
+ i64 i;
356414
356714
 
356415
356715
  /* Scan backwards looking for the signature bytes */
356416
356716
  for(i=nRead-20; i>=0; i--){
@@ -356421,9 +356721,7 @@ static int zipfileReadEOCD(
356421
356721
  }
356422
356722
  }
356423
356723
  if( i<0 ){
356424
- pTab->base.zErrMsg = sqlite3_mprintf(
356425
- "cannot find end of central directory record"
356426
- );
356724
+ zipfileTableErr(pTab, "cannot find end of central directory record");
356427
356725
  return SQLITE_ERROR;
356428
356726
  }
356429
356727
 
@@ -356468,7 +356766,7 @@ static void zipfileAddEntry(
356468
356766
  }
356469
356767
  }
356470
356768
 
356471
- static int zipfileLoadDirectory(ZipfileTab *pTab, const u8 *aBlob, int nBlob){
356769
+ static int zipfileLoadDirectory(ZipfileTab *pTab, const u8 *aBlob, i64 nBlob){
356472
356770
  ZipfileEOCD eocd;
356473
356771
  int rc;
356474
356772
  int i;
@@ -356516,7 +356814,7 @@ static int zipfileFilter(
356516
356814
  }else if( sqlite3_value_type(argv[0])==SQLITE_BLOB ){
356517
356815
  static const u8 aEmptyBlob = 0;
356518
356816
  const u8 *aBlob = (const u8*)sqlite3_value_blob(argv[0]);
356519
- int nBlob = sqlite3_value_bytes(argv[0]);
356817
+ i64 nBlob = sqlite3_value_bytes(argv[0]);
356520
356818
  assert( pTab->pFirstEntry==0 );
356521
356819
  if( aBlob==0 ){
356522
356820
  aBlob = &aEmptyBlob;
@@ -356714,7 +357012,7 @@ static int zipfileBegin(sqlite3_vtab *pVtab){
356714
357012
 
356715
357013
  assert( pTab->pWriteFd==0 );
356716
357014
  if( pTab->zFile==0 || pTab->zFile[0]==0 ){
356717
- pTab->base.zErrMsg = sqlite3_mprintf("zipfile: missing filename");
357015
+ zipfileTableErr(pTab, "zipfile: missing filename");
356718
357016
  return SQLITE_ERROR;
356719
357017
  }
356720
357018
 
@@ -356724,9 +357022,9 @@ static int zipfileBegin(sqlite3_vtab *pVtab){
356724
357022
  ** in main-memory until the transaction is committed. */
356725
357023
  pTab->pWriteFd = sqlite3_fopen(pTab->zFile, "ab+");
356726
357024
  if( pTab->pWriteFd==0 ){
356727
- pTab->base.zErrMsg = sqlite3_mprintf(
356728
- "zipfile: failed to open file %s for writing", pTab->zFile
356729
- );
357025
+ zipfileTableErr(pTab,
357026
+ "zipfile: failed to open file %s for writing", pTab->zFile
357027
+ );
356730
357028
  rc = SQLITE_ERROR;
356731
357029
  }else{
356732
357030
  fseek(pTab->pWriteFd, 0, SEEK_END);
@@ -357191,7 +357489,7 @@ struct ZipfileCtx {
357191
357489
  ZipfileBuffer cds;
357192
357490
  };
357193
357491
 
357194
- static int zipfileBufferGrow(ZipfileBuffer *pBuf, int nByte){
357492
+ static int zipfileBufferGrow(ZipfileBuffer *pBuf, i64 nByte){
357195
357493
  if( pBuf->n+nByte>pBuf->nAlloc ){
357196
357494
  u8 *aNew;
357197
357495
  sqlite3_int64 nNew = pBuf->n ? pBuf->n*2 : 512;
@@ -357240,7 +357538,7 @@ static void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
357240
357538
  char *zName = 0; /* Path (name) of new entry */
357241
357539
  int nName = 0; /* Size of zName in bytes */
357242
357540
  char *zFree = 0; /* Free this before returning */
357243
- int nByte;
357541
+ i64 nByte;
357244
357542
 
357245
357543
  memset(&e, 0, sizeof(e));
357246
357544
  p = (ZipfileCtx*)sqlite3_aggregate_context(pCtx, sizeof(ZipfileCtx));