Downloaded from https://www.sqlite.org/2015/sqlite3-3.8.6-patched-20150522.tar.gz $ sha256sum sqlite3-3.8.6-patched-20150522.tar.gz 0a47b495190a4def20a8f5f1b09f746f48f002d4d60bd6d0437b33a90faf8f70 sqlite3-3.8.6-patched-20150522.tar.gz dist/orig contains the stock sqlite3 code, as packaged in the ZIP file above. dist contains a copy of dist/orig, but with the Android.patch file applied. Please see Android.patch for a list of differences between stock and Android. This distribution contains 3.8.6 plus several security fixes: https://www.sqlite.org/src/info/eddc05e7bb31fae7 https://www.sqlite.org/src/info/02e3c88fbf6abdcf https://www.sqlite.org/src/info/c494171f77dc2e5e https://www.sqlite.org/src/info/95625ef3adc3c408 https://www.sqlite.org/src/info/0cdf502885ea7e58 https://www.sqlite.org/src/info/586a94e85bc13700 Bug: 20099586 Change-Id: I92ffb14b52186aa31167da21791ea8aa69b0b498 Signed-off-by: Firefly <service@t-firefly.com>
173 lines
5.4 KiB
Diff
173 lines
5.4 KiB
Diff
diff -r -u -d orig/shell.c ./shell.c
|
|
--- orig/shell.c 2015-08-26 20:14:53.502376811 -0400
|
|
+++ ./shell.c 2015-08-26 20:15:12.150229710 -0400
|
|
@@ -35,6 +35,11 @@
|
|
#include "sqlite3.h"
|
|
#include <ctype.h>
|
|
#include <stdarg.h>
|
|
+// Begin Android Add
|
|
+#ifndef NO_ANDROID_FUNCS
|
|
+#include <sqlite3_android.h>
|
|
+#endif
|
|
+// End Android Add
|
|
|
|
#if !defined(_WIN32) && !defined(WIN32)
|
|
# include <signal.h>
|
|
@@ -1737,6 +1742,21 @@
|
|
readfileFunc, 0, 0);
|
|
sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
|
|
writefileFunc, 0, 0);
|
|
+
|
|
+ // Begin Android Add
|
|
+ #ifndef NO_ANDROID_FUNCS
|
|
+ int err = register_localized_collators(db, "en_US", 0);
|
|
+ if (err != SQLITE_OK) {
|
|
+ fprintf(stderr, "register_localized_collators() failed\n");
|
|
+ exit(1);
|
|
+ }
|
|
+ err = register_android_functions(db, 0);
|
|
+ if (err != SQLITE_OK) {
|
|
+ fprintf(stderr, "register_android_functions() failed\n");
|
|
+ exit(1);
|
|
+ }
|
|
+ #endif
|
|
+ // End Android Add
|
|
}
|
|
}
|
|
|
|
diff -r -u -d orig/sqlite3.c ./sqlite3.c
|
|
--- orig/sqlite3.c 2015-08-26 20:14:53.518376684 -0400
|
|
+++ ./sqlite3.c 2015-08-26 20:15:12.150229710 -0400
|
|
@@ -24115,6 +24115,13 @@
|
|
*/
|
|
#if SQLITE_OS_UNIX /* This file is used on unix only */
|
|
|
|
+/* Use posix_fallocate() if it is available
|
|
+*/
|
|
+#if !defined(HAVE_POSIX_FALLOCATE) \
|
|
+ && (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L)
|
|
+# define HAVE_POSIX_FALLOCATE 1
|
|
+#endif
|
|
+
|
|
/*
|
|
** There are various methods for file locking used for concurrency
|
|
** control:
|
|
@@ -24666,7 +24673,12 @@
|
|
#else
|
|
{ "pread64", (sqlite3_syscall_ptr)0, 0 },
|
|
#endif
|
|
+#ifdef ANDROID
|
|
+// Bionic defines pread64 using off64_t rather than off_t.
|
|
+#define osPread64 ((ssize_t(*)(int,void*,size_t,off64_t))aSyscall[10].pCurrent)
|
|
+#else
|
|
#define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent)
|
|
+#endif
|
|
|
|
{ "write", (sqlite3_syscall_ptr)write, 0 },
|
|
#define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)
|
|
@@ -24684,8 +24696,14 @@
|
|
#else
|
|
{ "pwrite64", (sqlite3_syscall_ptr)0, 0 },
|
|
#endif
|
|
+#ifdef ANDROID
|
|
+// Bionic defines pwrite64 using off64_t rather than off_t.
|
|
+#define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off64_t))\
|
|
+ aSyscall[13].pCurrent)
|
|
+#else
|
|
#define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off_t))\
|
|
aSyscall[13].pCurrent)
|
|
+#endif
|
|
|
|
{ "fchmod", (sqlite3_syscall_ptr)fchmod, 0 },
|
|
#define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent)
|
|
@@ -27915,7 +27933,7 @@
|
|
SimulateIOError( rc=1 );
|
|
if( rc!=0 ){
|
|
((unixFile*)id)->lastErrno = errno;
|
|
- return SQLITE_IOERR_FSTAT;
|
|
+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath);
|
|
}
|
|
*pSize = buf.st_size;
|
|
|
|
@@ -27944,7 +27962,9 @@
|
|
i64 nSize; /* Required file size */
|
|
struct stat buf; /* Used to hold return values of fstat() */
|
|
|
|
- if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;
|
|
+ if( osFstat(pFile->h, &buf) ) {
|
|
+ return unixLogError(SQLITE_IOERR_FSTAT, "fstat", pFile->zPath);
|
|
+ }
|
|
|
|
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
|
|
if( nSize>(i64)buf.st_size ){
|
|
@@ -28516,7 +28536,7 @@
|
|
** with the same permissions.
|
|
*/
|
|
if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){
|
|
- rc = SQLITE_IOERR_FSTAT;
|
|
+ rc = unixLogError(SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath);
|
|
goto shm_open_err;
|
|
}
|
|
|
|
@@ -29848,7 +29868,7 @@
|
|
*pUid = sStat.st_uid;
|
|
*pGid = sStat.st_gid;
|
|
}else{
|
|
- rc = SQLITE_IOERR_FSTAT;
|
|
+ rc = unixLogError(SQLITE_IOERR_FSTAT, "stat", zDb);
|
|
}
|
|
}else if( flags & SQLITE_OPEN_DELETEONCLOSE ){
|
|
*pMode = 0600;
|
|
@@ -100894,7 +100914,7 @@
|
|
}
|
|
if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
|
|
sqlite3SetString(pzErrMsg, db, "unsupported file format");
|
|
- rc = SQLITE_ERROR;
|
|
+ rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;"
|
|
goto initone_error_out;
|
|
}
|
|
|
|
@@ -124770,9 +124790,9 @@
|
|
#endif
|
|
|
|
#ifdef SQLITE_ENABLE_FTS3
|
|
- if( !db->mallocFailed && rc==SQLITE_OK ){
|
|
- rc = sqlite3Fts3Init(db);
|
|
- }
|
|
+ if( !db->mallocFailed && rc==SQLITE_OK ){
|
|
+ rc = sqlite3Fts3Init(db);
|
|
+ }
|
|
#endif
|
|
|
|
#ifdef SQLITE_ENABLE_ICU
|
|
@@ -130716,16 +130736,28 @@
|
|
** module with sqlite.
|
|
*/
|
|
if( SQLITE_OK==rc
|
|
+#ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
|
|
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
|
|
+#endif
|
|
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
|
|
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
|
|
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
|
|
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
|
|
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
|
|
){
|
|
+#ifdef SQLITE_ENABLE_FTS3_BACKWARDS
|
|
+ rc = sqlite3_create_module_v2(
|
|
+ db, "fts1", &fts3Module, (void *)pHash, 0
|
|
+ );
|
|
+ if(rc) return rc;
|
|
+ rc = sqlite3_create_module_v2(
|
|
+ db, "fts2", &fts3Module, (void *)pHash, 0
|
|
+ );
|
|
+ if(rc) return rc;
|
|
+#endif
|
|
rc = sqlite3_create_module_v2(
|
|
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
|
|
- );
|
|
+ );
|
|
if( rc==SQLITE_OK ){
|
|
rc = sqlite3_create_module_v2(
|
|
db, "fts4", &fts3Module, (void *)pHash, 0
|