@@ -33395,6 +33395,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
3339533395# include <sys/mount.h>
3339633396#endif
3339733397
33398+ #if defined(__BIONIC__)
33399+ # include <android/fdsan.h>
33400+ #endif
33401+
3339833402#ifdef HAVE_UTIME
3339933403# include <utime.h>
3340033404#endif
@@ -34155,6 +34159,12 @@ static int robust_open(const char *z, int f, mode_t m){
3415534159#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
3415634160 osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
3415734161#endif
34162+
34163+ #if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
34164+ uint64_t tag = android_fdsan_create_owner_tag(
34165+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, fd);
34166+ android_fdsan_exchange_owner_tag(fd, 0, tag);
34167+ #endif
3415834168 }
3415934169 return fd;
3416034170}
@@ -34735,7 +34745,13 @@ static int unixLogErrorAtLine(
3473534745** and move on.
3473634746*/
3473734747static void robust_close(unixFile *pFile, int h, int lineno){
34748+ #if defined(__BIONIC__) && __ANDROID_API__ >= __ANDROID_API_Q__
34749+ uint64_t tag = android_fdsan_create_owner_tag(
34750+ ANDROID_FDSAN_OWNER_TYPE_SQLITE, h);
34751+ if( android_fdsan_close_with_tag(h, tag) ){
34752+ #else
3473834753 if( osClose(h) ){
34754+ #endif
3473934755 unixLogErrorAtLine(SQLITE_IOERR_CLOSE, "close",
3474034756 pFile ? pFile->zPath : 0, lineno);
3474134757 }
@@ -37269,7 +37285,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
3726937285 SimulateIOError( rc=1 );
3727037286 if( rc!=0 ){
3727137287 storeLastErrno((unixFile*)id, errno);
37272- return SQLITE_IOERR_FSTAT;
37288+ return unixLogError( SQLITE_IOERR_FSTAT, "fstat", ((unixFile*)id)->zPath) ;
3727337289 }
3727437290 *pSize = buf.st_size;
3727537291
@@ -37305,7 +37321,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
3730537321 struct stat buf; /* Used to hold return values of fstat() */
3730637322
3730737323 if( osFstat(pFile->h, &buf) ){
37308- return SQLITE_IOERR_FSTAT;
37324+ return unixLogError( SQLITE_IOERR_FSTAT, "fstat", pFile->zPath) ;
3730937325 }
3731037326
3731137327 nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
@@ -38000,7 +38016,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
3800038016 ** with the same permissions.
3800138017 */
3800238018 if( osFstat(pDbFd->h, &sStat) ){
38003- rc = SQLITE_IOERR_FSTAT;
38019+ rc = unixLogError( SQLITE_IOERR_FSTAT, "fstat", pDbFd->zPath) ;
3800438020 goto shm_open_err;
3800538021 }
3800638022
@@ -128218,7 +128234,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
128218128234 }
128219128235 if( pDb->pSchema->file_format>SQLITE_MAX_FILE_FORMAT ){
128220128236 sqlite3SetString(pzErrMsg, db, "unsupported file format");
128221- rc = SQLITE_ERROR;
128237+ rc = SQLITE_CORRUPT_BKPT; // Android Change from "rc = SQLITE_ERROR;" ;
128222128238 goto initone_error_out;
128223128239 }
128224128240
@@ -170128,13 +170144,25 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
170128170144 ** module with sqlite.
170129170145 */
170130170146 if( SQLITE_OK==rc
170147+ #ifndef ANDROID /* fts3_tokenizer disabled for security reasons */
170131170148 && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
170149+ #endif
170132170150 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
170133170151 && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
170134170152 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
170135170153 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
170136170154 && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
170137170155 ){
170156+ #ifdef SQLITE_ENABLE_FTS3_BACKWARDS
170157+ rc = sqlite3_create_module_v2(
170158+ db, "fts1", &fts3Module, (void *)pHash, 0
170159+ );
170160+ if(rc) return rc;
170161+ rc = sqlite3_create_module_v2(
170162+ db, "fts2", &fts3Module, (void *)pHash, 0
170163+ );
170164+ if(rc) return rc;
170165+ #endif
170138170166 rc = sqlite3_create_module_v2(
170139170167 db, "fts3", &fts3Module, (void *)pHash, hashDestroy
170140170168 );
0 commit comments