Skip to content

Commit

Permalink
Prepare release of wxSQLite3 4.4.3
Browse files Browse the repository at this point in the history
Update to SQLite3 version 3.28.0
  • Loading branch information
utelle committed May 18, 2019
1 parent 3a06d5b commit 13b3140
Show file tree
Hide file tree
Showing 19 changed files with 5,092 additions and 3,766 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dnl Copyright (C) 2017-2018 Ulrich Telle <[email protected]>, Vadim Zeitlin
dnl
dnl This file is covered by the same licence as the entire wxSQLite3 package.

AC_INIT([wxsqlite3], [4.4.2], [[email protected]])
AC_INIT([wxsqlite3], [4.4.3], [[email protected]])

dnl This is the version tested with, might work with earlier ones.
AC_PREREQ([2.69])
Expand Down
2 changes: 1 addition & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = wxSQLite3
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 4.4.2
PROJECT_NUMBER = 4.4.3

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
4 changes: 2 additions & 2 deletions include/wx/wxsqlite3_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

#define WXSQLITE3_MAJOR_VERSION 4
#define WXSQLITE3_MINOR_VERSION 4
#define WXSQLITE3_RELEASE_NUMBER 2
#define WXSQLITE3_RELEASE_NUMBER 3
#define WXSQLITE3_SUBRELEASE_NUMBER 0
#define WXSQLITE3_VERSION_STRING "wxSQLite3 4.4.2"
#define WXSQLITE3_VERSION_STRING "wxSQLite3 4.4.3"

#endif // _WXSQLITE3_VERSION_H_
5 changes: 5 additions & 0 deletions include/wx/wxsqlite3def.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
<dl>
<dt><b>4.4.3</b> - <i>May 2019</i></dt>
<dd>
Upgrade to SQLite version 3.28.0<br>
</dd>
<dt><b>4.4.2</b> - <i>February 2019</i></dt>
<dd>
Upgrade to SQLite version 3.27.2<br>
Expand Down
10 changes: 10 additions & 0 deletions include/wx/wxsqlite3dyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ DYNFUNC(return, int, sqlite3_step, (sqlite3_s
#if SQLITE_VERSION_NUMBER >= 3007010
DYNFUNC(return, int, sqlite3_stmt_busy, (sqlite3_stmt* pStmt), (pStmt));
#endif
#if SQLITE_VERSION_NUMBER >= 3028000
DYNFUNC(return, int, sqlite3_stmt_isexplain, (sqlite3_stmt* pStmt), (pStmt));
#endif
#if SQLITE_VERSION_NUMBER >= 3007004
DYNFUNC(return, int, sqlite3_stmt_readonly, (sqlite3_stmt *pStmt), (pStmt));
#endif
Expand All @@ -213,8 +216,15 @@ DYNFUNC(return, const void *, sqlite3_value_blob, (sqlite3_v
DYNFUNC(return, int, sqlite3_value_bytes, (sqlite3_value *pVal), (pVal));
// DYNFUNC(return, int, sqlite3_value_bytes16, (sqlite3_value *pVal), (pVal));
DYNFUNC(return, double, sqlite3_value_double, (sqlite3_value *pVal), (pVal));
#if SQLITE_VERSION_NUMBER >= 3028000
DYNFUNC(return, int, sqlite3_value_frombind, (sqlite3_value *pVal), (pVal));
#endif
DYNFUNC(return, int, sqlite3_value_int, (sqlite3_value *pVal), (pVal));
DYNFUNC(return, sqlite_int64, sqlite3_value_int64, (sqlite3_value *pVal), (pVal));
#if SQLITE_VERSION_NUMBER >= 3022000
DYNFUNC(return, int, sqlite3_value_nochange, (sqlite3_value *pVal), (pVal));
#endif
DYNFUNC(return, int, sqlite3_value_numeric_type, (sqlite3_value *pVal), (pVal));
#if SQLITE_VERSION_NUMBER >= 3020000
DYNFUNC(return, void *, sqlite3_value_pointer, (sqlite3_value *pVal, const char* ptrtype), (pVal, ptrtype));
#endif
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Currently the following encryption schemes are supported:

## <a name="history"></a>Version history

* 4.4.3 - *May 2019*
- Upgrade to SQLite version 3.28.0
* 4.4.2 - *February 2019*
- Upgrade to SQLite version 3.27.2
* 4.4.1 - *February 2019*
Expand Down
2 changes: 1 addition & 1 deletion sqlite3secure/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dnl Copyright (C) 2018 Ulrich Telle <[email protected]>
dnl
dnl This file is covered by the same licence as the entire wxSQLite3 package.

AC_INIT([sqlite3secure], [3.27.2], [[email protected]])
AC_INIT([sqlite3secure], [3.28.0], [[email protected]])

dnl This is the version tested with, might work with earlier ones.
AC_PREREQ([2.69])
Expand Down
2 changes: 1 addition & 1 deletion sqlite3secure/readme-precompiled.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release notes

February 28, 2019
May 18, 2019

The SQLite3 shell applications are now compatible with the official
SQLite3 shell in respect to the compile time options
Expand Down
14 changes: 8 additions & 6 deletions sqlite3secure/rekeyvacuum.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/sh
# Generate rekeyvacuum.c from SQLite3 amalgamation and print it to stdout.
# Generate rekeyvacuum.c from SQLite3 amalgamation and write it to stdout.
# Usage: ./script/rekeyvacuum.sh sqlite3.c >rekeyvacuum.c

if [ "$#" -ne 1 ] || ! [ "$1" = "-" -o -f "$1" ]; then
INPUT="$([ "$#" -eq 1 ] && echo "$1" || echo "sqlite3.c")"
if ! [ -f "$INPUT" ]; then
echo "Usage: $0 <SQLITE3_AMALGAMATION>" >&2
echo " e.g.: $0 sqlite3.c" >&2
exit 1
Expand All @@ -12,8 +14,8 @@ die() {
exit 2
}

VERSION="$(sed -n 's/^#define SQLITE_VERSION[^"]*"\([0-9]\+\.[0-9]\+\.[0-9]\+\)"$/\1/p' sqlite3.h)"
[ -z "$VERSION" ] && die "Cannot find SQLite3 version"
VERSION="$(sed -n 's/^#define SQLITE_VERSION[^"]*"\([0-9]\+\.[0-9]\+\.[0-9]\+\)"$/\1/p' "$INPUT")"
[ -z "$VERSION" ] && die "cannot find SQLite3 version (is '$INPUT' a valid amalgamation?)"

cat <<EOF
/*
Expand Down Expand Up @@ -43,10 +45,10 @@ cat <<EOF
** Change 2: Remove local variable 'int nRes'
** Change 3: Remove initialization 'nRes = sqlite3BtreeGetOptimalReserve(pMain)'
**
** This code is generated by the script rekeyvacuum.sh from SQLite version $VERSION.
** This code is generated by the script rekeyvacuum.sh from SQLite version $VERSION amalgamation.
*/
EOF
sed -n '/^SQLITE_PRIVATE int sqlite3RunVacuum([^;]*$/,/^}$/p' "$1" \
sed -n '/^SQLITE_PRIVATE .*int sqlite3RunVacuum([^;]*$/,/^}$/p' "$INPUT" \
| sed 's/sqlite3RunVacuum/sqlite3RunVacuumForRekey/' \
| sed 's/^\([^ )][^)]*\)\?){$/\1, int nRes){/' \
| grep -v "int nRes;\|nRes = " \
Expand Down
42 changes: 22 additions & 20 deletions sqlite3secure/src/chacha20poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static void chacha20_block(unsigned char out[64], const uint32_t in[16])
void chacha20_xor(unsigned char* data, size_t n, const unsigned char key[32],
const unsigned char nonce[12], uint32_t counter)
{
size_t i;
int i;
uint32_t state[16];
unsigned char block[64];
static const unsigned char sigma[16] = "expand 32-byte k";
Expand Down Expand Up @@ -139,23 +139,21 @@ void chacha20_xor(unsigned char* data, size_t n, const unsigned char key[32],
void poly1305(const unsigned char* msg, size_t n, const unsigned char key[32],
unsigned char tag[16])
{
uint32_t c, m, w;
uint32_t hibit, m, w;
uint32_t r0, r1, r2, r3, r4;
uint32_t s1, s2, s3, s4;
uint64_t f0, f1, f2, f3;
uint32_t g0, g1, g2, g3, g4;
uint32_t h0, h1, h2, h3, h4;
unsigned char buf[16];
size_t i;

c = 1 << 24;
r0 = (LOAD32_LE(key + 0) >> 0) & 0x03FFFFFF;
r1 = (LOAD32_LE(key + 3) >> 2) & 0x03FFFF03;
r2 = (LOAD32_LE(key + 6) >> 4) & 0x03FFC0FF;
r3 = (LOAD32_LE(key + 9) >> 6) & 0x03F03FFF;
r4 = (LOAD32_LE(key + 12) >> 8) & 0x000FFFFF;
s1 = r1 * 5; s2 = r2 * 5; s3 = r3 * 5; s4 = r4 * 5;
hibit = 1 << 24;
h0 = h1 = h2 = h3 = h4 = 0;
r0 = (LOAD32_LE(key + 0) >> 0) & 0x03FFFFFF;
r1 = (LOAD32_LE(key + 3) >> 2) & 0x03FFFF03; s1 = r1 * 5;
r2 = (LOAD32_LE(key + 6) >> 4) & 0x03FFC0FF; s2 = r2 * 5;
r3 = (LOAD32_LE(key + 9) >> 6) & 0x03F03FFF; s3 = r3 * 5;
r4 = (LOAD32_LE(key + 12) >> 8) & 0x000FFFFF; s4 = r4 * 5;
while (n >= 16)
{
uint64_t d0, d1, d2, d3, d4;
Expand All @@ -164,7 +162,7 @@ void poly1305(const unsigned char* msg, size_t n, const unsigned char key[32],
h1 += (LOAD32_LE(msg + 3) >> 2) & 0x03FFFFFF;
h2 += (LOAD32_LE(msg + 6) >> 4) & 0x03FFFFFF;
h3 += (LOAD32_LE(msg + 9) >> 6) & 0x03FFFFFF;
h4 += (LOAD32_LE(msg + 12) >> 8) | c;
h4 += (LOAD32_LE(msg + 12) >> 8) | hibit;

#define MUL(a,b) ((uint64_t)(a) * (b))
d0 = MUL(h0,r0) + MUL(h1,s4) + MUL(h2,s3) + MUL(h3,s2) + MUL(h4,s1);
Expand All @@ -186,12 +184,13 @@ void poly1305(const unsigned char* msg, size_t n, const unsigned char key[32],
}
if (n)
{
int i;
for (i = 0; i < n; i++) buf[i] = msg[i];
buf[i++] = 1;
while (i < 16) buf[i++] = 0;
msg = buf;
hibit = 0;
n = 16;
c = 0;
goto process_block;
}
*(volatile uint32_t*) &r0 = 0;
Expand Down Expand Up @@ -219,10 +218,10 @@ void poly1305(const unsigned char* msg, size_t n, const unsigned char key[32],
h3 = (h3 & w) | (g3 & m);
h4 = (h4 & w) | (g4 & m);

f0 = ((h0 >> 0) | (h1 << 26)) + (uint64_t) LOAD32_LE(&key[16]);
f1 = ((h1 >> 6) | (h2 << 20)) + (uint64_t) LOAD32_LE(&key[20]);
f2 = ((h2 >> 12) | (h3 << 14)) + (uint64_t) LOAD32_LE(&key[24]);
f3 = ((h3 >> 18) | (h4 << 8)) + (uint64_t) LOAD32_LE(&key[28]);
f0 = ((h0 >> 0) | (h1 << 26)) + (uint64_t) LOAD32_LE(key + 16);
f1 = ((h1 >> 6) | (h2 << 20)) + (uint64_t) LOAD32_LE(key + 20);
f2 = ((h2 >> 12) | (h3 << 14)) + (uint64_t) LOAD32_LE(key + 24);
f3 = ((h3 >> 18) | (h4 << 8)) + (uint64_t) LOAD32_LE(key + 28);

STORE32_LE(tag + 0, f0); f1 += (f0 >> 32);
STORE32_LE(tag + 4, f1); f2 += (f1 >> 32);
Expand Down Expand Up @@ -255,7 +254,7 @@ int poly1305_tagcmp(const unsigned char tag1[16], const unsigned char tag2[16])
/*
* Platform-specific entropy functions for seeding RNG
*/
#if defined(__unix__) || defined(__APPLE__)
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__)
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
Expand All @@ -266,8 +265,11 @@ int poly1305_tagcmp(const unsigned char tag1[16], const unsigned char tag2[16])
#include <unistd.h>

#ifdef __linux__
#include <linux/random.h>
#include <sys/ioctl.h>
/* musl does not have <linux/random.h> so let's define RNDGETENTCNT here */
#ifndef RNDGETENTCNT
#define RNDGETENTCNT _IOR('R', 0x00, int)
#endif
#endif

/* Returns the number of urandom bytes read (either 0 or n) */
Expand Down Expand Up @@ -367,7 +369,7 @@ void chacha20_rng(void* out, size_t n)
static uint32_t counter = UINT32_MAX;
static unsigned char key[32], nonce[12], buffer[64] = { 0 };

#if SQLITE3_THREADSAFE
#if SQLITE_THREADSAFE
sqlite3_mutex* mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PRNG);
sqlite3_mutex_enter(mutex);
#endif
Expand All @@ -394,7 +396,7 @@ void chacha20_rng(void* out, size_t n)
n -= m;
}

#if SQLITE3_THREADSAFE
#if SQLITE_THREADSAFE
sqlite3_mutex_leave(mutex);
#endif
}
14 changes: 7 additions & 7 deletions sqlite3secure/src/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,13 @@ static void readFileContents(sqlite3_context *ctx, const char *zName){
fclose(in);
return;
}
pBuf = sqlite3_malloc64( nIn );
pBuf = sqlite3_malloc64( nIn ? nIn : 1 );
if( pBuf==0 ){
sqlite3_result_error_nomem(ctx);
fclose(in);
return;
}
if( 1==fread(pBuf, nIn, 1, in) ){
if( nIn==(sqlite3_int64)fread(pBuf, 1, (size_t)nIn, in) ){
sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free);
}else{
sqlite3_result_error_code(ctx, SQLITE_IOERR);
Expand Down Expand Up @@ -293,15 +293,15 @@ static int fileLinkStat(
** Argument zFile is the name of a file that will be created and/or written
** by SQL function writefile(). This function ensures that the directory
** zFile will be written to exists, creating it if required. The permissions
** for any path components created by this function are set to (mode&0777).
** for any path components created by this function are set in accordance
** with the current umask.
**
** If an OOM condition is encountered, SQLITE_NOMEM is returned. Otherwise,
** SQLITE_OK is returned if the directory is successfully created, or
** SQLITE_ERROR otherwise.
*/
static int makeDirectory(
const char *zFile,
mode_t mode
const char *zFile
){
char *zCopy = sqlite3_mprintf("%s", zFile);
int rc = SQLITE_OK;
Expand All @@ -322,7 +322,7 @@ static int makeDirectory(

rc2 = fileStat(zCopy, &sStat);
if( rc2!=0 ){
if( mkdir(zCopy, mode & 0777) ) rc = SQLITE_ERROR;
if( mkdir(zCopy, 0777) ) rc = SQLITE_ERROR;
}else{
if( !S_ISDIR(sStat.st_mode) ) rc = SQLITE_ERROR;
}
Expand Down Expand Up @@ -480,7 +480,7 @@ static void writefileFunc(

res = writeFile(context, zFile, argv[1], mode, mtime);
if( res==1 && errno==ENOENT ){
if( makeDirectory(zFile, mode)==SQLITE_OK ){
if( makeDirectory(zFile)==SQLITE_OK ){
res = writeFile(context, zFile, argv[1], mode, mtime);
}
}
Expand Down
16 changes: 11 additions & 5 deletions sqlite3secure/src/rekeyvacuum.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
** Change 2: Remove local variable 'int nRes'
** Change 3: Remove initialization 'nRes = sqlite3BtreeGetOptimalReserve(pMain)'
**
** This code is generated by the script rekeyvacuum.sh from SQLite version 3.27.1.
** This code is generated by the script rekeyvacuum.sh from SQLite version 3.28.0 amalgamation.
*/
SQLITE_PRIVATE int sqlite3RunVacuumForRekey(
SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3RunVacuumForRekey(
char **pzErrMsg, /* Write error message here */
sqlite3 *db, /* Database connection */
int iDb, /* Which attached DB to vacuum */
sqlite3_value *pOut /* Write results here, if not NULL */
sqlite3_value *pOut /* Write results here, if not NULL. VACUUM INTO */
, int nRes){
int rc = SQLITE_OK; /* Return code from service routines */
Btree *pMain; /* The database being vacuumed */
Expand All @@ -40,6 +40,7 @@ SQLITE_PRIVATE int sqlite3RunVacuumForRekey(
u64 saved_flags; /* Saved value of db->flags */
int saved_nChange; /* Saved value of db->nChange */
int saved_nTotalChange; /* Saved value of db->nTotalChange */
u32 saved_openFlags; /* Saved value of db->openFlags */
u8 saved_mTrace; /* Saved trace settings */
Db *pDb = 0; /* Database to detach at end of vacuum */
int isMemDb; /* True if vacuuming a :memory: database */
Expand All @@ -49,18 +50,21 @@ SQLITE_PRIVATE int sqlite3RunVacuumForRekey(

if( !db->autoCommit ){
sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
return SQLITE_ERROR;
return SQLITE_ERROR; /* IMP: R-12218-18073 */
}
if( db->nVdbeActive>1 ){
sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
return SQLITE_ERROR;
return SQLITE_ERROR; /* IMP: R-15610-35227 */
}
saved_openFlags = db->openFlags;
if( pOut ){
if( sqlite3_value_type(pOut)!=SQLITE_TEXT ){
sqlite3SetString(pzErrMsg, db, "non-text filename");
return SQLITE_ERROR;
}
zOut = (const char*)sqlite3_value_text(pOut);
db->openFlags &= ~SQLITE_OPEN_READONLY;
db->openFlags |= SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE;
}else{
zOut = "";
}
Expand Down Expand Up @@ -99,6 +103,7 @@ SQLITE_PRIVATE int sqlite3RunVacuumForRekey(
*/
nDb = db->nDb;
rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut);
db->openFlags = saved_openFlags;
if( rc!=SQLITE_OK ) goto end_of_vacuum;
assert( (db->nDb-1)==nDb );
pDb = &db->aDb[nDb];
Expand All @@ -112,6 +117,7 @@ SQLITE_PRIVATE int sqlite3RunVacuumForRekey(
sqlite3SetString(pzErrMsg, db, "output file already exists");
goto end_of_vacuum;
}
db->mDbFlags |= DBFLAG_VacuumInto;
}

/* A VACUUM cannot change the pagesize of an encrypted database. */
Expand Down
Loading

0 comments on commit 13b3140

Please sign in to comment.