better-sqlite3-multiple-ciphers 8.7.0 → 9.0.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.
- package/README.md +7 -7
- package/binding.gyp +1 -0
- package/deps/setup.ps1 +1 -1
- package/deps/sqlite3/sqlite3.c +368 -31
- package/deps/sqlite3/sqlite3.h +6 -6
- package/package.json +2 -8
package/README.md
CHANGED
|
@@ -17,16 +17,16 @@ The fastest and simplest library for SQLite3 in Node.js. This particular fork su
|
|
|
17
17
|
## Current versions
|
|
18
18
|
|
|
19
19
|
- ### Stable
|
|
20
|
-
- **better-sqlite3-multiple-ciphers** - [`
|
|
21
|
-
- **better-sqlite3** - [`
|
|
22
|
-
- **SQLite** - [`3.43.
|
|
23
|
-
- **SQLite3 Multiple Ciphers** - [`1.
|
|
20
|
+
- **better-sqlite3-multiple-ciphers** - [`9.0.0`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v9.0.0)
|
|
21
|
+
- **better-sqlite3** - [`9.0.0`](https://github.com/JoshuaWise/better-sqlite3/releases/tag/v9.0.0)
|
|
22
|
+
- **SQLite** - [`3.43.2`](https://www.sqlite.org/releaselog/3_43_2.html)
|
|
23
|
+
- **SQLite3 Multiple Ciphers** - [`1.7.2`](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.7.2)
|
|
24
24
|
|
|
25
25
|
- ### Beta
|
|
26
|
-
- **better-sqlite3-multiple-ciphers** - [`v8.
|
|
27
|
-
- **better-sqlite3** - [`8.
|
|
26
|
+
- **better-sqlite3-multiple-ciphers** - [`v8.7.1-beta.0`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v8.7.1-beta.0)
|
|
27
|
+
- **better-sqlite3** - [`8.7.0`](https://github.com/JoshuaWise/better-sqlite3/releases/tag/v8.7.0)
|
|
28
28
|
- **SQLite** - [`3.43.1`](https://www.sqlite.org/releaselog/3_43_1.html)
|
|
29
|
-
- **SQLite3 Multiple Ciphers** - [`1.
|
|
29
|
+
- **SQLite3 Multiple Ciphers** - [`1.7.0`](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.7.0)
|
|
30
30
|
|
|
31
31
|
## Help this project stay strong! 💪
|
|
32
32
|
|
package/binding.gyp
CHANGED
package/deps/setup.ps1
CHANGED
package/deps/sqlite3/sqlite3.c
CHANGED
|
@@ -92,7 +92,7 @@ extern SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
|
|
|
92
92
|
/*** Begin of #include "sqlite3patched.c" ***/
|
|
93
93
|
/******************************************************************************
|
|
94
94
|
** This file is an amalgamation of many separate C source files from SQLite
|
|
95
|
-
** version 3.43.
|
|
95
|
+
** version 3.43.2. By combining all the individual C code files into this
|
|
96
96
|
** single large file, the entire code can be compiled as a single translation
|
|
97
97
|
** unit. This allows many compilers to do optimizations that would not be
|
|
98
98
|
** possible if the files were compiled separately. Performance improvements
|
|
@@ -110,7 +110,7 @@ extern SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
|
|
|
110
110
|
** separate file. This file contains only code for the core SQLite library.
|
|
111
111
|
**
|
|
112
112
|
** The content in this amalgamation comes from Fossil check-in
|
|
113
|
-
**
|
|
113
|
+
** 310099cce5a487035fa535dd3002c59ac7f.
|
|
114
114
|
*/
|
|
115
115
|
#define SQLITE_CORE 1
|
|
116
116
|
#define SQLITE_AMALGAMATION 1
|
|
@@ -551,9 +551,9 @@ extern "C" {
|
|
|
551
551
|
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
|
552
552
|
** [sqlite_version()] and [sqlite_source_id()].
|
|
553
553
|
*/
|
|
554
|
-
#define SQLITE_VERSION "3.43.
|
|
555
|
-
#define SQLITE_VERSION_NUMBER
|
|
556
|
-
#define SQLITE_SOURCE_ID "2023-
|
|
554
|
+
#define SQLITE_VERSION "3.43.2"
|
|
555
|
+
#define SQLITE_VERSION_NUMBER 3043002
|
|
556
|
+
#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790"
|
|
557
557
|
|
|
558
558
|
/*
|
|
559
559
|
** CAPI3REF: Run-Time Library Version Numbers
|
|
@@ -11084,6 +11084,9 @@ SQLITE_PRIVATE int sqlite3mcHandleAttachKey(sqlite3*, const char*, const char*,
|
|
|
11084
11084
|
SQLITE_PRIVATE int sqlite3mcHandleMainKey(sqlite3*, const char*);
|
|
11085
11085
|
typedef struct PgHdr PgHdrMC;
|
|
11086
11086
|
SQLITE_PRIVATE void* sqlite3mcPagerCodec(PgHdrMC* pPg);
|
|
11087
|
+
typedef struct Pager PagerMC;
|
|
11088
|
+
SQLITE_PRIVATE int sqlite3mcPagerHasCodec(PagerMC* pPager);
|
|
11089
|
+
SQLITE_PRIVATE void sqlite3mcInitMemoryMethods();
|
|
11087
11090
|
|
|
11088
11091
|
/******** Begin file sqlite3rtree.h *********/
|
|
11089
11092
|
/*
|
|
@@ -29807,6 +29810,12 @@ SQLITE_PRIVATE int sqlite3MallocInit(void){
|
|
|
29807
29810
|
}
|
|
29808
29811
|
rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
|
|
29809
29812
|
if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));
|
|
29813
|
+
|
|
29814
|
+
/* Initialize wrapper for memory management.*/
|
|
29815
|
+
if( rc==SQLITE_OK ) {
|
|
29816
|
+
sqlite3mcInitMemoryMethods();
|
|
29817
|
+
}
|
|
29818
|
+
|
|
29810
29819
|
return rc;
|
|
29811
29820
|
}
|
|
29812
29821
|
|
|
@@ -35285,29 +35294,29 @@ SQLITE_PRIVATE void sqlite3FpDecode(FpDecode *p, double r, int iRound, int mxRou
|
|
|
35285
35294
|
double rr[2];
|
|
35286
35295
|
rr[0] = r;
|
|
35287
35296
|
rr[1] = 0.0;
|
|
35288
|
-
if( rr[0]>
|
|
35289
|
-
while( rr[0]>
|
|
35297
|
+
if( rr[0]>9.223372036854774784e+18 ){
|
|
35298
|
+
while( rr[0]>9.223372036854774784e+118 ){
|
|
35290
35299
|
exp += 100;
|
|
35291
35300
|
dekkerMul2(rr, 1.0e-100, -1.99918998026028836196e-117);
|
|
35292
35301
|
}
|
|
35293
|
-
while( rr[0]>
|
|
35302
|
+
while( rr[0]>9.223372036854774784e+28 ){
|
|
35294
35303
|
exp += 10;
|
|
35295
35304
|
dekkerMul2(rr, 1.0e-10, -3.6432197315497741579e-27);
|
|
35296
35305
|
}
|
|
35297
|
-
while( rr[0]>
|
|
35306
|
+
while( rr[0]>9.223372036854774784e+18 ){
|
|
35298
35307
|
exp += 1;
|
|
35299
35308
|
dekkerMul2(rr, 1.0e-01, -5.5511151231257827021e-18);
|
|
35300
35309
|
}
|
|
35301
35310
|
}else{
|
|
35302
|
-
while( rr[0]<
|
|
35311
|
+
while( rr[0]<9.223372036854774784e-83 ){
|
|
35303
35312
|
exp -= 100;
|
|
35304
35313
|
dekkerMul2(rr, 1.0e+100, -1.5902891109759918046e+83);
|
|
35305
35314
|
}
|
|
35306
|
-
while( rr[0]<
|
|
35315
|
+
while( rr[0]<9.223372036854774784e+07 ){
|
|
35307
35316
|
exp -= 10;
|
|
35308
35317
|
dekkerMul2(rr, 1.0e+10, 0.0);
|
|
35309
35318
|
}
|
|
35310
|
-
while( rr[0]<
|
|
35319
|
+
while( rr[0]<9.22337203685477478e+17 ){
|
|
35311
35320
|
exp -= 1;
|
|
35312
35321
|
dekkerMul2(rr, 1.0e+01, 0.0);
|
|
35313
35322
|
}
|
|
@@ -57156,6 +57165,7 @@ static const unsigned char aJournalMagic[] = {
|
|
|
57156
57165
|
SQLITE_PRIVATE int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){
|
|
57157
57166
|
if( pPager->fd->pMethods==0 ) return 0;
|
|
57158
57167
|
if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;
|
|
57168
|
+
if( sqlite3mcPagerHasCodec(pPager) != 0 ) return 0;
|
|
57159
57169
|
#ifndef SQLITE_OMIT_WAL
|
|
57160
57170
|
if( pPager->pWal ){
|
|
57161
57171
|
u32 iRead = 0;
|
|
@@ -57389,7 +57399,7 @@ static void setGetterMethod(Pager *pPager){
|
|
|
57389
57399
|
if( pPager->errCode ){
|
|
57390
57400
|
pPager->xGet = getPageError;
|
|
57391
57401
|
#if SQLITE_MAX_MMAP_SIZE>0
|
|
57392
|
-
}else if( USEFETCH(pPager) ){
|
|
57402
|
+
}else if( USEFETCH(pPager) && sqlite3mcPagerHasCodec(pPager) == 0 ){
|
|
57393
57403
|
pPager->xGet = getPageMMap;
|
|
57394
57404
|
#endif /* SQLITE_MAX_MMAP_SIZE>0 */
|
|
57395
57405
|
}else{
|
|
@@ -77128,6 +77138,7 @@ static int rebuildPage(
|
|
|
77128
77138
|
int k; /* Current slot in pCArray->apEnd[] */
|
|
77129
77139
|
u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */
|
|
77130
77140
|
|
|
77141
|
+
assert( nCell>0 );
|
|
77131
77142
|
assert( i<iEnd );
|
|
77132
77143
|
j = get2byte(&aData[hdr+5]);
|
|
77133
77144
|
if( NEVER(j>(u32)usableSize) ){ j = 0; }
|
|
@@ -77434,6 +77445,7 @@ static int editPage(
|
|
|
77434
77445
|
return SQLITE_OK;
|
|
77435
77446
|
editpage_fail:
|
|
77436
77447
|
/* Unable to edit this page. Rebuild it from scratch instead. */
|
|
77448
|
+
if( nNew<1 ) return SQLITE_CORRUPT_BKPT;
|
|
77437
77449
|
populateCellCache(pCArray, iNew, nNew);
|
|
77438
77450
|
return rebuildPage(pCArray, iNew, nNew, pPg);
|
|
77439
77451
|
}
|
|
@@ -100937,8 +100949,7 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
|
|
|
100937
100949
|
/* Set the value of register r[1] in the SQL statement to integer iRow.
|
|
100938
100950
|
** This is done directly as a performance optimization
|
|
100939
100951
|
*/
|
|
100940
|
-
v->aMem[1]
|
|
100941
|
-
v->aMem[1].u.i = iRow;
|
|
100952
|
+
sqlite3VdbeMemSetInt64(&v->aMem[1], iRow);
|
|
100942
100953
|
|
|
100943
100954
|
/* If the statement has been run before (and is paused at the OP_ResultRow)
|
|
100944
100955
|
** then back it up to the point where it does the OP_NotExists. This could
|
|
@@ -204253,6 +204264,7 @@ static void jsonReplaceFunc(
|
|
|
204253
204264
|
}
|
|
204254
204265
|
pParse = jsonParseCached(ctx, argv[0], ctx, argc>1);
|
|
204255
204266
|
if( pParse==0 ) return;
|
|
204267
|
+
pParse->nJPRef++;
|
|
204256
204268
|
for(i=1; i<(u32)argc; i+=2){
|
|
204257
204269
|
zPath = (const char*)sqlite3_value_text(argv[i]);
|
|
204258
204270
|
pParse->useMod = 1;
|
|
@@ -204265,6 +204277,7 @@ static void jsonReplaceFunc(
|
|
|
204265
204277
|
jsonReturnJson(pParse, pParse->aNode, ctx, 1);
|
|
204266
204278
|
replace_err:
|
|
204267
204279
|
jsonDebugPrintParse(pParse);
|
|
204280
|
+
jsonParseFree(pParse);
|
|
204268
204281
|
}
|
|
204269
204282
|
|
|
204270
204283
|
|
|
@@ -204299,6 +204312,7 @@ static void jsonSetFunc(
|
|
|
204299
204312
|
}
|
|
204300
204313
|
pParse = jsonParseCached(ctx, argv[0], ctx, argc>1);
|
|
204301
204314
|
if( pParse==0 ) return;
|
|
204315
|
+
pParse->nJPRef++;
|
|
204302
204316
|
for(i=1; i<(u32)argc; i+=2){
|
|
204303
204317
|
zPath = (const char*)sqlite3_value_text(argv[i]);
|
|
204304
204318
|
bApnd = 0;
|
|
@@ -204315,9 +204329,8 @@ static void jsonSetFunc(
|
|
|
204315
204329
|
}
|
|
204316
204330
|
jsonDebugPrintParse(pParse);
|
|
204317
204331
|
jsonReturnJson(pParse, pParse->aNode, ctx, 1);
|
|
204318
|
-
|
|
204319
204332
|
jsonSetDone:
|
|
204320
|
-
|
|
204333
|
+
jsonParseFree(pParse);
|
|
204321
204334
|
}
|
|
204322
204335
|
|
|
204323
204336
|
/*
|
|
@@ -239806,7 +239819,6 @@ static void fts5DoSecureDelete(
|
|
|
239806
239819
|
int iIdx = 0;
|
|
239807
239820
|
int iStart = 0;
|
|
239808
239821
|
int iKeyOff = 0;
|
|
239809
|
-
int iPrevKeyOff = 0;
|
|
239810
239822
|
int iDelKeyOff = 0; /* Offset of deleted key, if any */
|
|
239811
239823
|
|
|
239812
239824
|
nIdx = nPg-iPgIdx;
|
|
@@ -244368,6 +244380,9 @@ static int fts5FilterMethod(
|
|
|
244368
244380
|
pCsr->iFirstRowid = fts5GetRowidLimit(pRowidGe, SMALLEST_INT64);
|
|
244369
244381
|
}
|
|
244370
244382
|
|
|
244383
|
+
rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
|
|
244384
|
+
if( rc!=SQLITE_OK ) goto filter_out;
|
|
244385
|
+
|
|
244371
244386
|
if( pTab->pSortCsr ){
|
|
244372
244387
|
/* If pSortCsr is non-NULL, then this call is being made as part of
|
|
244373
244388
|
** processing for a "... MATCH <expr> ORDER BY rank" query (ePlan is
|
|
@@ -244390,7 +244405,9 @@ static int fts5FilterMethod(
|
|
|
244390
244405
|
pCsr->pExpr = pTab->pSortCsr->pExpr;
|
|
244391
244406
|
rc = fts5CursorFirst(pTab, pCsr, bDesc);
|
|
244392
244407
|
}else if( pCsr->pExpr ){
|
|
244393
|
-
|
|
244408
|
+
if( rc==SQLITE_OK ){
|
|
244409
|
+
rc = fts5CursorParseRank(pConfig, pCsr, pRank);
|
|
244410
|
+
}
|
|
244394
244411
|
if( rc==SQLITE_OK ){
|
|
244395
244412
|
if( bOrderByRank ){
|
|
244396
244413
|
pCsr->ePlan = FTS5_PLAN_SORTED_MATCH;
|
|
@@ -245871,7 +245888,7 @@ static void fts5SourceIdFunc(
|
|
|
245871
245888
|
){
|
|
245872
245889
|
assert( nArg==0 );
|
|
245873
245890
|
UNUSED_PARAM2(nArg, apUnused);
|
|
245874
|
-
sqlite3_result_text(pCtx, "fts5: 2023-
|
|
245891
|
+
sqlite3_result_text(pCtx, "fts5: 2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790", -1, SQLITE_TRANSIENT);
|
|
245875
245892
|
}
|
|
245876
245893
|
|
|
245877
245894
|
/*
|
|
@@ -251128,10 +251145,10 @@ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
|
|
|
251128
251145
|
#define SQLITE3MC_VERSION_H_
|
|
251129
251146
|
|
|
251130
251147
|
#define SQLITE3MC_VERSION_MAJOR 1
|
|
251131
|
-
#define SQLITE3MC_VERSION_MINOR
|
|
251132
|
-
#define SQLITE3MC_VERSION_RELEASE
|
|
251148
|
+
#define SQLITE3MC_VERSION_MINOR 7
|
|
251149
|
+
#define SQLITE3MC_VERSION_RELEASE 2
|
|
251133
251150
|
#define SQLITE3MC_VERSION_SUBRELEASE 0
|
|
251134
|
-
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.
|
|
251151
|
+
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.7.2"
|
|
251135
251152
|
|
|
251136
251153
|
#endif /* SQLITE3MC_VERSION_H_ */
|
|
251137
251154
|
/*** End of #include "sqlite3mc_version.h" ***/
|
|
@@ -251290,9 +251307,9 @@ extern "C" {
|
|
|
251290
251307
|
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
|
251291
251308
|
** [sqlite_version()] and [sqlite_source_id()].
|
|
251292
251309
|
*/
|
|
251293
|
-
#define SQLITE_VERSION "3.43.
|
|
251294
|
-
#define SQLITE_VERSION_NUMBER
|
|
251295
|
-
#define SQLITE_SOURCE_ID "2023-
|
|
251310
|
+
#define SQLITE_VERSION "3.43.2"
|
|
251311
|
+
#define SQLITE_VERSION_NUMBER 3043002
|
|
251312
|
+
#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790"
|
|
251296
251313
|
|
|
251297
251314
|
/*
|
|
251298
251315
|
** CAPI3REF: Run-Time Library Version Numbers
|
|
@@ -264601,6 +264618,31 @@ sqlite3mcVersion(sqlite3_context* context, int argc, sqlite3_value** argv)
|
|
|
264601
264618
|
sqlite3_result_text(context, sqlite3mc_version(), -1, 0);
|
|
264602
264619
|
}
|
|
264603
264620
|
|
|
264621
|
+
#ifndef SQLITE3MC_SECURE_MEMORY
|
|
264622
|
+
#define SQLITE3MC_SECURE_MEMORY 0
|
|
264623
|
+
#endif
|
|
264624
|
+
|
|
264625
|
+
#if SQLITE3MC_SECURE_MEMORY
|
|
264626
|
+
|
|
264627
|
+
#define SECURE_MEMORY_NONE 0
|
|
264628
|
+
#define SECURE_MEMORY_FILL 1
|
|
264629
|
+
#define SECURE_MEMORY_LOCK 2
|
|
264630
|
+
|
|
264631
|
+
SQLITE_PRIVATE void sqlite3mcSetMemorySecurity(int value);
|
|
264632
|
+
SQLITE_PRIVATE int sqlite3mcGetMemorySecurity();
|
|
264633
|
+
|
|
264634
|
+
#ifndef SQLITE3MC_USE_RANDOM_FILL_MEMORY
|
|
264635
|
+
#define SQLITE3MC_USE_RANDOM_FILL_MEMORY 0
|
|
264636
|
+
#endif
|
|
264637
|
+
|
|
264638
|
+
/* Memory locking is currently not supported */
|
|
264639
|
+
#ifdef SQLITE3MC_ENABLE_MEMLOCK
|
|
264640
|
+
#undef SQLITE3MC_ENABLE_MEMLOCK
|
|
264641
|
+
#endif
|
|
264642
|
+
#define SQLITE3MC_ENABLE_MEMLOCK 0
|
|
264643
|
+
|
|
264644
|
+
#endif
|
|
264645
|
+
|
|
264604
264646
|
/*
|
|
264605
264647
|
** Crypto algorithms
|
|
264606
264648
|
*/
|
|
@@ -267348,14 +267390,14 @@ fail:
|
|
|
267348
267390
|
return 0;
|
|
267349
267391
|
}
|
|
267350
267392
|
|
|
267351
|
-
#if defined(__APPLE__)
|
|
267352
|
-
#include <
|
|
267393
|
+
#if defined(__APPLE__)
|
|
267394
|
+
#include <Security/SecRandom.h>
|
|
267353
267395
|
#endif
|
|
267354
267396
|
|
|
267355
267397
|
static size_t entropy(void* buf, size_t n)
|
|
267356
267398
|
{
|
|
267357
|
-
#if defined(__APPLE__)
|
|
267358
|
-
if (
|
|
267399
|
+
#if defined(__APPLE__)
|
|
267400
|
+
if (SecRandomCopyBytes(kSecRandomDefault, n, (uint8_t*) buf) == 0)
|
|
267359
267401
|
return n;
|
|
267360
267402
|
#elif defined(__linux__) && defined(SYS_getrandom)
|
|
267361
267403
|
if (syscall(SYS_getrandom, buf, n, 0) == n)
|
|
@@ -268102,6 +268144,8 @@ void RijndaelDecrypt(Rijndael* rijndael, UINT8 a[16], UINT8 b[16]);
|
|
|
268102
268144
|
#define AES_HARDWARE_NI 1
|
|
268103
268145
|
#define AES_HARDWARE_NEON 2
|
|
268104
268146
|
|
|
268147
|
+
#ifndef SQLITE3MC_OMIT_AES_HARDWARE_SUPPORT
|
|
268148
|
+
|
|
268105
268149
|
#if defined __ARM_FEATURE_CRYPTO
|
|
268106
268150
|
#define HAS_AES_HARDWARE AES_HARDWARE_NEON
|
|
268107
268151
|
|
|
@@ -268159,6 +268203,14 @@ void RijndaelDecrypt(Rijndael* rijndael, UINT8 a[16], UINT8 b[16]);
|
|
|
268159
268203
|
|
|
268160
268204
|
#endif
|
|
268161
268205
|
|
|
268206
|
+
#else /* SQLITE3MC_OMIT_AES_HARDWARE_SUPPORT defined */
|
|
268207
|
+
|
|
268208
|
+
/* Omit AES hardware support */
|
|
268209
|
+
#define HAS_AES_HARDWARE AES_HARDWARE_NONE
|
|
268210
|
+
|
|
268211
|
+
#endif /* SQLITE3MC_OMIT_AES_HARDWARE_SUPPORT */
|
|
268212
|
+
|
|
268213
|
+
|
|
268162
268214
|
#if HAS_AES_HARDWARE != AES_HARDWARE_NONE
|
|
268163
268215
|
/* --- Implementation of common data and functions for any AES hardware --- */
|
|
268164
268216
|
|
|
@@ -274343,6 +274395,54 @@ sqlite3mcFileControlPragma(sqlite3* db, const char* zDbName, int op, void* pArg)
|
|
|
274343
274395
|
((char**)pArg)[0] = sqlite3_mprintf("Malformed hex string");
|
|
274344
274396
|
}
|
|
274345
274397
|
}
|
|
274398
|
+
#if SQLITE3MC_SECURE_MEMORY
|
|
274399
|
+
else if (sqlite3StrICmp(pragmaName, "memory_security") == 0)
|
|
274400
|
+
{
|
|
274401
|
+
if (pragmaValue)
|
|
274402
|
+
{
|
|
274403
|
+
int intValue = -1;
|
|
274404
|
+
if (0 == sqlite3StrICmp(pragmaValue, "none"))
|
|
274405
|
+
{
|
|
274406
|
+
intValue = SECURE_MEMORY_NONE;
|
|
274407
|
+
}
|
|
274408
|
+
else if (0 == sqlite3StrICmp(pragmaValue, "fill") )
|
|
274409
|
+
{
|
|
274410
|
+
intValue = SECURE_MEMORY_FILL;
|
|
274411
|
+
}
|
|
274412
|
+
#if SQLITE3MC_ENABLE_MEMLOCK
|
|
274413
|
+
else if (0 == sqlite3StrICmp(pragmaValue, "lock") )
|
|
274414
|
+
{
|
|
274415
|
+
intValue = SECURE_MEMORY_LOCK;
|
|
274416
|
+
}
|
|
274417
|
+
#endif
|
|
274418
|
+
else
|
|
274419
|
+
{
|
|
274420
|
+
intValue = sqlite3Atoi(pragmaValue);
|
|
274421
|
+
#if SQLITE3MC_ENABLE_MEMLOCK
|
|
274422
|
+
intValue = (intValue >=0 && intValue <= 2) ? intValue : -1;
|
|
274423
|
+
#else
|
|
274424
|
+
intValue = (intValue >=0 && intValue <= 1) ? intValue : -1;
|
|
274425
|
+
#endif
|
|
274426
|
+
}
|
|
274427
|
+
if (intValue >= 0)
|
|
274428
|
+
{
|
|
274429
|
+
sqlite3mcSetMemorySecurity(intValue);
|
|
274430
|
+
rc = SQLITE_OK;
|
|
274431
|
+
((char**)pArg)[0] = sqlite3_mprintf("%d", intValue);
|
|
274432
|
+
}
|
|
274433
|
+
else
|
|
274434
|
+
{
|
|
274435
|
+
rc = SQLITE_ERROR;
|
|
274436
|
+
((char**) pArg)[0] = sqlite3_mprintf("Secure memory option '%s' invalid.", pragmaValue);
|
|
274437
|
+
}
|
|
274438
|
+
}
|
|
274439
|
+
else
|
|
274440
|
+
{
|
|
274441
|
+
rc = SQLITE_OK;
|
|
274442
|
+
((char**)pArg)[0] = sqlite3_mprintf("%d", sqlite3mcGetMemorySecurity());
|
|
274443
|
+
}
|
|
274444
|
+
}
|
|
274445
|
+
#endif /* SQLITE3MC_SECURE_MEMORY */
|
|
274346
274446
|
else
|
|
274347
274447
|
{
|
|
274348
274448
|
int j;
|
|
@@ -274569,7 +274669,7 @@ sqlite3mcBtreeSetPageSize(Btree* p, int pageSize, int nReserve, int iFix)
|
|
|
274569
274669
|
** Change 4: Call sqlite3mcBtreeSetPageSize instead of sqlite3BtreeSetPageSize for main database
|
|
274570
274670
|
** (sqlite3mcBtreeSetPageSize allows to reduce the number of reserved bytes)
|
|
274571
274671
|
**
|
|
274572
|
-
** This code is generated by the script rekeyvacuum.sh from SQLite version 3.43.
|
|
274672
|
+
** This code is generated by the script rekeyvacuum.sh from SQLite version 3.43.2 amalgamation.
|
|
274573
274673
|
*/
|
|
274574
274674
|
SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3mcRunVacuumForRekey(
|
|
274575
274675
|
char **pzErrMsg, /* Write error message here */
|
|
@@ -275418,6 +275518,212 @@ sqlite3_rekey(sqlite3 *db, const void *zKey, int nKey)
|
|
|
275418
275518
|
/*** End of #include "codecext.c" ***/
|
|
275419
275519
|
|
|
275420
275520
|
|
|
275521
|
+
/*
|
|
275522
|
+
** Functions for securing allocated memory
|
|
275523
|
+
*/
|
|
275524
|
+
/* #include "memory_secure.c" */
|
|
275525
|
+
/*** Begin of #include "memory_secure.c" ***/
|
|
275526
|
+
/*
|
|
275527
|
+
** Name: mem_secure.c
|
|
275528
|
+
** Purpose: Memory manager for SQLite3 Multiple Ciphers
|
|
275529
|
+
** Author: Ulrich Telle
|
|
275530
|
+
** Created: 2023-09-17
|
|
275531
|
+
** Copyright: (c) 2023 Ulrich Telle
|
|
275532
|
+
** License: MIT
|
|
275533
|
+
*/
|
|
275534
|
+
|
|
275535
|
+
#if SQLITE3MC_SECURE_MEMORY
|
|
275536
|
+
|
|
275537
|
+
/* Flag indicating whether securing memory allocations is initialized */
|
|
275538
|
+
static volatile int mcSecureMemoryInitialized = 0;
|
|
275539
|
+
/* Flag indicating whether memory allocations will be secured */
|
|
275540
|
+
static volatile int mcSecureMemoryFlag = 0;
|
|
275541
|
+
|
|
275542
|
+
/* Map of default memory allocation methods */
|
|
275543
|
+
static volatile sqlite3_mem_methods mcDefaultMemoryMethods;
|
|
275544
|
+
|
|
275545
|
+
#if SQLITE3MC_ENABLE_RANDOM_FILL_MEMORY
|
|
275546
|
+
|
|
275547
|
+
/*
|
|
275548
|
+
** Fill a buffer with pseudo-random bytes. This is used to preset
|
|
275549
|
+
** the content of a new memory allocation to unpredictable values and
|
|
275550
|
+
** to clear the content of a freed allocation to unpredictable values.
|
|
275551
|
+
*/
|
|
275552
|
+
static void mcRandomFill(char* pBuf, int nByte)
|
|
275553
|
+
{
|
|
275554
|
+
unsigned int x, y, r;
|
|
275555
|
+
x = SQLITE_PTR_TO_INT(pBuf);
|
|
275556
|
+
y = nByte | 1;
|
|
275557
|
+
while( nByte >= 4 )
|
|
275558
|
+
{
|
|
275559
|
+
x = (x>>1) ^ (-(int)(x&1) & 0xd0000001);
|
|
275560
|
+
y = y*1103515245 + 12345;
|
|
275561
|
+
r = x ^ y;
|
|
275562
|
+
*(int*)pBuf = r;
|
|
275563
|
+
pBuf += 4;
|
|
275564
|
+
nByte -= 4;
|
|
275565
|
+
}
|
|
275566
|
+
while( nByte-- > 0 )
|
|
275567
|
+
{
|
|
275568
|
+
x = (x>>1) ^ (-(int)(x&1) & 0xd0000001);
|
|
275569
|
+
y = y*1103515245 + 12345;
|
|
275570
|
+
r = x ^ y;
|
|
275571
|
+
*(pBuf++) = r & 0xff;
|
|
275572
|
+
}
|
|
275573
|
+
}
|
|
275574
|
+
|
|
275575
|
+
#endif
|
|
275576
|
+
|
|
275577
|
+
/*
|
|
275578
|
+
** Return the size of an allocation
|
|
275579
|
+
*/
|
|
275580
|
+
static int mcMemorySize(void* pBuf)
|
|
275581
|
+
{
|
|
275582
|
+
return mcDefaultMemoryMethods.xSize(pBuf);
|
|
275583
|
+
}
|
|
275584
|
+
|
|
275585
|
+
/*
|
|
275586
|
+
** Memory allocation function
|
|
275587
|
+
*/
|
|
275588
|
+
static void* mcMemoryAlloc(int nByte)
|
|
275589
|
+
{
|
|
275590
|
+
return mcDefaultMemoryMethods.xMalloc(nByte);
|
|
275591
|
+
}
|
|
275592
|
+
|
|
275593
|
+
/*
|
|
275594
|
+
** Free a prior allocation
|
|
275595
|
+
*/
|
|
275596
|
+
static void mcMemoryFree(void* pPrior)
|
|
275597
|
+
{
|
|
275598
|
+
if (mcSecureMemoryFlag)
|
|
275599
|
+
{
|
|
275600
|
+
#if SQLITE3MC_USE_RANDOM_FILL_MEMORY
|
|
275601
|
+
int nSize = mcMemorySize(pPrior);
|
|
275602
|
+
mcRandomFill((char*) pPrior, nSize)
|
|
275603
|
+
#else
|
|
275604
|
+
int nSize = mcMemorySize(pPrior);
|
|
275605
|
+
memset(pPrior, 0, nSize);
|
|
275606
|
+
#endif
|
|
275607
|
+
}
|
|
275608
|
+
mcDefaultMemoryMethods.xFree(pPrior);
|
|
275609
|
+
}
|
|
275610
|
+
|
|
275611
|
+
/*
|
|
275612
|
+
** Resize an allocation
|
|
275613
|
+
*/
|
|
275614
|
+
static void* mcMemoryRealloc(void* pPrior, int nByte)
|
|
275615
|
+
{
|
|
275616
|
+
void* pNew = NULL;
|
|
275617
|
+
if (mcSecureMemoryFlag)
|
|
275618
|
+
{
|
|
275619
|
+
int nPriorSize = mcMemorySize(pPrior);
|
|
275620
|
+
if (nByte == 0)
|
|
275621
|
+
{
|
|
275622
|
+
/* New size = 0, just free prior memory */
|
|
275623
|
+
mcMemoryFree(pPrior);
|
|
275624
|
+
return NULL;
|
|
275625
|
+
}
|
|
275626
|
+
else if (!pPrior)
|
|
275627
|
+
{
|
|
275628
|
+
/* Prior size = 0, just allocate new memory */
|
|
275629
|
+
return mcMemoryAlloc(nByte);
|
|
275630
|
+
}
|
|
275631
|
+
else if(nByte <= nPriorSize)
|
|
275632
|
+
{
|
|
275633
|
+
/* New size less or equal prior size, do nothing - we do not shrink allocations */
|
|
275634
|
+
return pPrior;
|
|
275635
|
+
}
|
|
275636
|
+
else
|
|
275637
|
+
{
|
|
275638
|
+
/* New size greater than prior size, reallocate memory */
|
|
275639
|
+
pNew = mcMemoryAlloc(nByte);
|
|
275640
|
+
if (pNew)
|
|
275641
|
+
{
|
|
275642
|
+
memcpy(pNew, pPrior, nPriorSize);
|
|
275643
|
+
mcMemoryFree(pPrior);
|
|
275644
|
+
}
|
|
275645
|
+
return pNew;
|
|
275646
|
+
}
|
|
275647
|
+
}
|
|
275648
|
+
else
|
|
275649
|
+
{
|
|
275650
|
+
return mcDefaultMemoryMethods.xRealloc(pPrior, nByte);
|
|
275651
|
+
}
|
|
275652
|
+
}
|
|
275653
|
+
|
|
275654
|
+
/*
|
|
275655
|
+
** Round up request size to allocation size
|
|
275656
|
+
*/
|
|
275657
|
+
static int mcMemoryRoundup(int nByte)
|
|
275658
|
+
{
|
|
275659
|
+
return mcDefaultMemoryMethods.xRoundup(nByte);
|
|
275660
|
+
}
|
|
275661
|
+
|
|
275662
|
+
/*
|
|
275663
|
+
** Initialize the memory allocator
|
|
275664
|
+
*/
|
|
275665
|
+
static int mcMemoryInit(void* pAppData)
|
|
275666
|
+
{
|
|
275667
|
+
return mcDefaultMemoryMethods.xInit(pAppData);
|
|
275668
|
+
}
|
|
275669
|
+
|
|
275670
|
+
/*
|
|
275671
|
+
** Deinitialize the memory allocator
|
|
275672
|
+
*/
|
|
275673
|
+
static void mcMemoryShutdown(void* pAppData)
|
|
275674
|
+
{
|
|
275675
|
+
mcDefaultMemoryMethods.xShutdown(pAppData);
|
|
275676
|
+
}
|
|
275677
|
+
|
|
275678
|
+
static sqlite3_mem_methods mcSecureMemoryMethods =
|
|
275679
|
+
{
|
|
275680
|
+
mcMemoryAlloc,
|
|
275681
|
+
mcMemoryFree,
|
|
275682
|
+
mcMemoryRealloc,
|
|
275683
|
+
mcMemorySize,
|
|
275684
|
+
mcMemoryRoundup,
|
|
275685
|
+
mcMemoryInit,
|
|
275686
|
+
mcMemoryShutdown,
|
|
275687
|
+
0
|
|
275688
|
+
};
|
|
275689
|
+
|
|
275690
|
+
SQLITE_PRIVATE void sqlite3mcSetMemorySecurity(int value)
|
|
275691
|
+
{
|
|
275692
|
+
/* memory security can be changed only, if locking is not enabled */
|
|
275693
|
+
if (mcSecureMemoryFlag < 2)
|
|
275694
|
+
{
|
|
275695
|
+
mcSecureMemoryFlag = (value >= 0 && value <= 2) ? value : 0;
|
|
275696
|
+
}
|
|
275697
|
+
}
|
|
275698
|
+
|
|
275699
|
+
SQLITE_PRIVATE int sqlite3mcGetMemorySecurity()
|
|
275700
|
+
{
|
|
275701
|
+
return mcSecureMemoryFlag;
|
|
275702
|
+
}
|
|
275703
|
+
|
|
275704
|
+
#endif /* SQLITE3MC_SECURE_MEMORY */
|
|
275705
|
+
|
|
275706
|
+
SQLITE_PRIVATE void sqlite3mcInitMemoryMethods()
|
|
275707
|
+
{
|
|
275708
|
+
#if SQLITE3MC_SECURE_MEMORY
|
|
275709
|
+
if (!mcSecureMemoryInitialized)
|
|
275710
|
+
{
|
|
275711
|
+
if (sqlite3_config(SQLITE_CONFIG_GETMALLOC, &mcDefaultMemoryMethods) != SQLITE_OK ||
|
|
275712
|
+
sqlite3_config(SQLITE_CONFIG_MALLOC, &mcSecureMemoryMethods) != SQLITE_OK)
|
|
275713
|
+
{
|
|
275714
|
+
mcSecureMemoryFlag = mcSecureMemoryInitialized = 0;
|
|
275715
|
+
}
|
|
275716
|
+
else
|
|
275717
|
+
{
|
|
275718
|
+
mcSecureMemoryInitialized = 1;
|
|
275719
|
+
}
|
|
275720
|
+
}
|
|
275721
|
+
#endif /* SQLITE3MC_SECURE_MEMORY */
|
|
275722
|
+
}
|
|
275723
|
+
|
|
275724
|
+
/*** End of #include "memory_secure.c" ***/
|
|
275725
|
+
|
|
275726
|
+
|
|
275421
275727
|
/*
|
|
275422
275728
|
** Extension functions
|
|
275423
275729
|
*/
|
|
@@ -298610,6 +298916,37 @@ sqlite3mcCheckVfs(const char* zVfs)
|
|
|
298610
298916
|
return rc;
|
|
298611
298917
|
}
|
|
298612
298918
|
|
|
298919
|
+
SQLITE_PRIVATE int
|
|
298920
|
+
sqlite3mcPagerHasCodec(PagerMC* pPager)
|
|
298921
|
+
{
|
|
298922
|
+
int hasCodec = 0;
|
|
298923
|
+
sqlite3mc_vfs* pVfsMC = NULL;
|
|
298924
|
+
sqlite3_vfs* pVfs = pPager->pVfs;
|
|
298925
|
+
|
|
298926
|
+
/* Check whether the VFS stack of the pager contains a Multiple Ciphers VFS */
|
|
298927
|
+
for (; pVfs; pVfs = pVfs->pNext)
|
|
298928
|
+
{
|
|
298929
|
+
if (pVfs && pVfs->xOpen == mcVfsOpen)
|
|
298930
|
+
{
|
|
298931
|
+
/* Multiple Ciphers VFS found */
|
|
298932
|
+
pVfsMC = (sqlite3mc_vfs*)(pVfs);
|
|
298933
|
+
break;
|
|
298934
|
+
}
|
|
298935
|
+
}
|
|
298936
|
+
|
|
298937
|
+
/* Check whether codec is enabled for associated database file */
|
|
298938
|
+
if (pVfsMC)
|
|
298939
|
+
{
|
|
298940
|
+
sqlite3mc_file* mcFile = mcFindDbMainFileName(pVfsMC, pPager->zFilename);
|
|
298941
|
+
if (mcFile)
|
|
298942
|
+
{
|
|
298943
|
+
Codec* codec = mcFile->codec;
|
|
298944
|
+
hasCodec = (codec != 0 && sqlite3mcIsEncrypted(codec));
|
|
298945
|
+
}
|
|
298946
|
+
}
|
|
298947
|
+
return hasCodec;
|
|
298948
|
+
}
|
|
298949
|
+
|
|
298613
298950
|
/*
|
|
298614
298951
|
** SQLite3 Multiple Ciphers external API functions
|
|
298615
298952
|
*/
|
package/deps/sqlite3/sqlite3.h
CHANGED
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
#define SQLITE3MC_VERSION_H_
|
|
31
31
|
|
|
32
32
|
#define SQLITE3MC_VERSION_MAJOR 1
|
|
33
|
-
#define SQLITE3MC_VERSION_MINOR
|
|
34
|
-
#define SQLITE3MC_VERSION_RELEASE
|
|
33
|
+
#define SQLITE3MC_VERSION_MINOR 7
|
|
34
|
+
#define SQLITE3MC_VERSION_RELEASE 2
|
|
35
35
|
#define SQLITE3MC_VERSION_SUBRELEASE 0
|
|
36
|
-
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.
|
|
36
|
+
#define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.7.2"
|
|
37
37
|
|
|
38
38
|
#endif /* SQLITE3MC_VERSION_H_ */
|
|
39
39
|
/*** End of #include "sqlite3mc_version.h" ***/
|
|
@@ -192,9 +192,9 @@ extern "C" {
|
|
|
192
192
|
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
|
193
193
|
** [sqlite_version()] and [sqlite_source_id()].
|
|
194
194
|
*/
|
|
195
|
-
#define SQLITE_VERSION "3.43.
|
|
196
|
-
#define SQLITE_VERSION_NUMBER
|
|
197
|
-
#define SQLITE_SOURCE_ID "2023-
|
|
195
|
+
#define SQLITE_VERSION "3.43.2"
|
|
196
|
+
#define SQLITE_VERSION_NUMBER 3043002
|
|
197
|
+
#define SQLITE_SOURCE_ID "2023-10-10 12:14:04 4310099cce5a487035fa535dd3002c59ac7f1d1bec68d7cf317fd3e769484790"
|
|
198
198
|
|
|
199
199
|
/*
|
|
200
200
|
** CAPI3REF: Run-Time Library Version Numbers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-sqlite3-multiple-ciphers",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "better-sqlite3 with multiple-cipher encryption support",
|
|
5
5
|
"homepage": "https://github.com/m4heshd/better-sqlite3-multiple-ciphers",
|
|
6
6
|
"author": "Mahesh Bandara Wijerathna (m4heshd) <m4heshd@gmail.com>",
|
|
@@ -27,17 +27,11 @@
|
|
|
27
27
|
"cli-color": "^2.0.3",
|
|
28
28
|
"fs-extra": "^11.1.1",
|
|
29
29
|
"mocha": "^10.2.0",
|
|
30
|
-
"node-gyp": "9.4.0",
|
|
31
30
|
"nodemark": "^0.3.0",
|
|
32
|
-
"prebuild": "^
|
|
31
|
+
"prebuild": "^12.0.0",
|
|
33
32
|
"sqlite": "^5.0.1",
|
|
34
33
|
"sqlite3": "^5.1.6"
|
|
35
34
|
},
|
|
36
|
-
"overrides": {
|
|
37
|
-
"prebuild": {
|
|
38
|
-
"node-gyp": "$node-gyp"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
35
|
"scripts": {
|
|
42
36
|
"install": "prebuild-install || node-gyp rebuild --release",
|
|
43
37
|
"build-release": "node-gyp rebuild --release",
|